Class: Nay::Template
- Inherits:
-
Object
- Object
- Nay::Template
- Defined in:
- lib/nay/template.rb
Overview
Built on top of the string-based Lexer/Evaluator but instead of only working for a string, this will recursively evaluate all strings within an object. Heuristics:
- Hashes will have their keys and parameters traversed
- Arrays will have their entries traversed
- Strings evaluate using Lexer
- All other types will simply return themselves (not be traversed or use the Lexer)
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #evaluate(parameters = {}) ⇒ Object
-
#initialize(object) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(object) ⇒ Template
Returns a new instance of Template.
16 17 18 19 20 |
# File 'lib/nay/template.rb', line 16 def initialize(object) @object = object freeze end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
14 15 16 |
# File 'lib/nay/template.rb', line 14 def object @object end |
Instance Method Details
#evaluate(parameters = {}) ⇒ Object
22 23 24 |
# File 'lib/nay/template.rb', line 22 def evaluate(parameters = {}) recursive_evaluate(object, parameters) end |