Class: LtdTemplate::Code::Sequence
- Inherits:
-
LtdTemplate::Code
- Object
- LtdTemplate::Code
- LtdTemplate::Code::Sequence
- Defined in:
- lib/ltdtemplate/code/sequence.rb
Instance Method Summary collapse
-
#evaluate(opts = {}) ⇒ Object
Evaluate the code sequence.
-
#initialize(template, code) ⇒ Sequence
constructor
A new instance of Sequence.
Methods inherited from LtdTemplate::Code
Constructor Details
#initialize(template, code) ⇒ Sequence
Returns a new instance of Sequence.
16 17 18 19 |
# File 'lib/ltdtemplate/code/sequence.rb', line 16 def initialize (template, code) super template @code = code end |
Instance Method Details
#evaluate(opts = {}) ⇒ Object
Evaluate the code sequence.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ltdtemplate/code/sequence.rb', line 22 def evaluate (opts = {}) values = @code.map do |code| # RESOURCE code_steps: Total number of code steps executed @template.use :code_steps rubyversed(code).evaluate end case values.size when 0 then nil when 1 then values[0] else values.map { |val| rubyversed(val).tpl_text }.join(''). tap { |res| @template.using :string_length, res.length } # RESOURCE string_length: Length of longest modified string end end |