Class: HackBoxen::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/hackboxen/template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_template, output_path, attributes) ⇒ Template

Returns a new instance of Template.



8
9
10
11
12
# File 'lib/hackboxen/template.rb', line 8

def initialize source_template, output_path, attributes
  @source_template = source_template
  @output_path     = output_path
  @attributes      = attributes
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



6
7
8
# File 'lib/hackboxen/template.rb', line 6

def attributes
  @attributes
end

#output_pathObject

Returns the value of attribute output_path.



6
7
8
# File 'lib/hackboxen/template.rb', line 6

def output_path
  @output_path
end

#source_templateObject

Returns the value of attribute source_template.



6
7
8
# File 'lib/hackboxen/template.rb', line 6

def source_template
  @source_template
end

Instance Method Details

#compile!Object



14
15
16
17
18
# File 'lib/hackboxen/template.rb', line 14

def compile!
  dest << Erubis::Eruby.new(source).result(attributes)
  dest << "\n"
  dest
end

#substitute!Object



20
21
22
# File 'lib/hackboxen/template.rb', line 20

def substitute!
  compile!
end