Class: N::Template
- Inherits:
-
Object
- Object
- N::Template
- Defined in:
- lib/n/utils/template.rb
Overview
Template
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
Instance Method Summary collapse
-
#gsub(hash) ⇒ Object
(also: #render)
Apply the substitutions to the template.
-
#initialize(filename) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(filename) ⇒ Template
Returns a new instance of Template.
20 21 22 |
# File 'lib/n/utils/template.rb', line 20 def initialize(filename) @body = File.read(filename) end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
16 17 18 |
# File 'lib/n/utils/template.rb', line 16 def body @body end |
Instance Method Details
#gsub(hash) ⇒ Object Also known as: render
Apply the substitutions to the template.
26 27 28 29 30 31 32 33 34 |
# File 'lib/n/utils/template.rb', line 26 def gsub(hash) res = body.dup() hash.each {|k, v| res.gsub!(k, v) } return res end |