Class: Linecook::Template
- Inherits:
-
Object
- Object
- Linecook::Template
- Defined in:
- lib/linecook/template.rb
Instance Attribute Summary collapse
-
#erb ⇒ Object
readonly
Returns the value of attribute erb.
Instance Method Summary collapse
- #build(locals = {}) ⇒ Object
-
#initialize(filename) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(filename) ⇒ Template
Returns a new instance of Template.
8 9 10 11 |
# File 'lib/linecook/template.rb', line 8 def initialize(filename) @erb = ERB.new File.read(filename) @erb.filename = filename end |
Instance Attribute Details
#erb ⇒ Object (readonly)
Returns the value of attribute erb.
6 7 8 |
# File 'lib/linecook/template.rb', line 6 def erb @erb end |
Instance Method Details
#build(locals = {}) ⇒ Object
13 14 15 |
# File 'lib/linecook/template.rb', line 13 def build(locals={}) erb.result OpenStruct.new(locals).instance_eval('binding') end |