Class: LtdTemplate::Value::Code_Block
- Defined in:
- lib/ltdtemplate/value/code_block.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Attributes inherited from Code
Instance Method Summary collapse
- #get_value(opts = {}) ⇒ Object
-
#initialize(template, code) ⇒ Code_Block
constructor
A new instance of Code_Block.
- #to_boolean ⇒ Object
- #to_native ⇒ Object
- #to_text ⇒ Object
-
#type ⇒ Object
Type (for :missing_method callback).
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
#code ⇒ Object (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_boolean ⇒ Object
23 |
# File 'lib/ltdtemplate/value/code_block.rb', line 23 def to_boolean; true; end |
#to_native ⇒ Object
24 |
# File 'lib/ltdtemplate/value/code_block.rb', line 24 def to_native; self; end |
#to_text ⇒ Object
25 |
# File 'lib/ltdtemplate/value/code_block.rb', line 25 def to_text; ''; end |
#type ⇒ Object
Type (for :missing_method callback)
41 |
# File 'lib/ltdtemplate/value/code_block.rb', line 41 def type; :code_block; end |