Class: LtdTemplate::Code::Code_Block

Inherits:
LtdTemplate::Code show all
Defined in:
lib/ltdtemplate/code/code_block.rb

Instance Attribute Summary

Attributes inherited from LtdTemplate::Code

#tpl_methods

Instance Method Summary collapse

Methods inherited from LtdTemplate::Code

#do_method, #do_set, #get_item, #has_item?, instance, #is_set?, #set_item, #set_value

Constructor Details

#initialize(template, code) ⇒ Code_Block

Returns a new instance of Code_Block.



16
17
18
19
# File 'lib/ltdtemplate/code/code_block.rb', line 16

def initialize (template, code)
	super template
	@code = code
end

Instance Method Details

#get_value(opts = {}) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/ltdtemplate/code/code_block.rb', line 21

def get_value (opts = {})
	values = @code.map { |part| part.get_value }.flatten
	case values.size
	when 0 then @template.factory :nil
	when 1 then values[0]
	else @template.factory(:array).set_value(values)
	end
end