Class: Embarista::DynamicIndex::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/embarista/dynamic_index/generator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(erb_path, context) ⇒ Generator

Returns a new instance of Generator.



6
7
8
9
# File 'lib/embarista/dynamic_index/generator.rb', line 6

def initialize(erb_path, context)
  @erb_path = erb_path
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/embarista/dynamic_index/generator.rb', line 4

def context
  @context
end

#erb_pathObject (readonly)

Returns the value of attribute erb_path.



4
5
6
# File 'lib/embarista/dynamic_index/generator.rb', line 4

def erb_path
  @erb_path
end

Class Method Details

.generator(erb_path, manifest_id, assets_base_url = App.assets_base_url) ⇒ Object



21
22
23
24
# File 'lib/embarista/dynamic_index/generator.rb', line 21

def self.generator(erb_path, manifest_id, assets_base_url=App.assets_base_url)
  context = Context.context(manifest_id, assets_base_url)
  self.new(erb_path, context)
end

Instance Method Details

#htmlObject



11
12
13
14
15
16
17
18
19
# File 'lib/embarista/dynamic_index/generator.rb', line 11

def html
  File.open(erb_path, 'r:UTF-8') do |f|
    erb = ERB.new(f.read, nil, '-')
    erb.filename = erb_path
    context.instance_eval do
      erb.result(binding)
    end
  end
end