Class: Swineherd::Template
- Inherits:
-
Object
- Object
- Swineherd::Template
- Defined in:
- lib/swineherd/template.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#source_template ⇒ Object
Returns the value of attribute source_template.
Instance Method Summary collapse
- #compile! ⇒ Object
-
#initialize(source_template, attributes) ⇒ Template
constructor
A new instance of Template.
- #substitute! ⇒ Object
Constructor Details
#initialize(source_template, attributes) ⇒ Template
Returns a new instance of Template.
12 13 14 15 |
# File 'lib/swineherd/template.rb', line 12 def initialize source_template, attributes @source_template = source_template @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
10 11 12 |
# File 'lib/swineherd/template.rb', line 10 def attributes @attributes end |
#source_template ⇒ Object
Returns the value of attribute source_template.
10 11 12 |
# File 'lib/swineherd/template.rb', line 10 def source_template @source_template end |
Instance Method Details
#compile! ⇒ Object
17 18 19 20 21 |
# File 'lib/swineherd/template.rb', line 17 def compile! dest << Erubis::Eruby.new(source).result(attributes) dest << "\n" dest end |
#substitute! ⇒ Object
23 24 25 26 27 |
# File 'lib/swineherd/template.rb', line 23 def substitute! compile! dest.read dest.path end |