Class: LtdTemplate::Value::Code_Block

Inherits:
Code
  • Object
show all
Defined in:
lib/ltdtemplate/value/code_block.rb

Instance Attribute Summary collapse

Attributes inherited from Code

#tpl_methods

Instance Method Summary collapse

Methods inherited from 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.



18
19
20
21
# File 'lib/ltdtemplate/value/code_block.rb', line 18

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

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

Instance Method Details

#get_value(opts = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ltdtemplate/value/code_block.rb', line 27

def get_value (opts = {})
	case opts[:method]
	when nil then self
	when 'type' then @template.factory :string, 'code'
	else
 @template.push_namespace opts[:method], opts[:parameters],
   :target => (opts[:target] || self)
 result = @code.get_value
 @template.pop_namespace
 result
	end
end

#to_booleanObject



23
# File 'lib/ltdtemplate/value/code_block.rb', line 23

def to_boolean; true; end

#to_nativeObject



24
# File 'lib/ltdtemplate/value/code_block.rb', line 24

def to_native; self; end

#to_textObject



25
# File 'lib/ltdtemplate/value/code_block.rb', line 25

def to_text; ''; end