summaryrefslogtreecommitdiff
path: root/new/lib/crys/processors/html_processor.rb
blob: bcc9768b27aab4980aa3cec094d0943903c5afb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'erb'
require_relative "common_functions"
require_relative "common_parts"

module Crys
  class HtmlProcessor

    include CommonFunctions
    include CommonParts
    
    def initialize(file_path:, image_dir:)
      @file_path = file_path
      @image_dir = image_dir
      @assets = []
    end

    def parsed_content
      html_file = ERB.new(File.read(file_path))
      html_file.result(local_binding)
    end

    def filename
      file_path.scan(/.*\/(.*)\.erb/).flatten.first
    end

    attr_reader :assets, :file_path

    private

    attr_reader :image_dir
    attr_writer :assets

    def local_binding
      local_binding ||= binding.clone
    end
  end
end