Class: Amrita2::Filters::Each
- Includes:
- Util::OptionSupport
- Defined in:
- lib/amrita2/template.rb
Instance Attribute Summary
Attributes included from Util::OptionSupport
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(*args) ⇒ Each
constructor
A new instance of Each.
- #value_filter_code(de, cg, value) ⇒ Object
Methods included from Util::OptionSupport
#[], #method_missing, #parse_opt
Methods inherited from Base
filter_method, inherited, #parse_filter_a, #|
Constructor Details
#initialize(*args) ⇒ Each
Returns a new instance of Each.
2192 2193 2194 |
# File 'lib/amrita2/template.rb', line 2192 def initialize(*args) parse_opt(*args) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Amrita2::Util::OptionSupport
Instance Method Details
#value_filter_code(de, cg, value) ⇒ Object
2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 |
# File 'lib/amrita2/template.rb', line 2196 def value_filter_code(de, cg, value) var = "__cnt__#{de.class_name}" @opt.each do |k,va| cg.code("#{var} = __cnt__%#{va.size}") va.each_with_index do |v, n| case v when Symbol cg.code("$_[#{k.inspect}] = $_[#{v.inspect}] if #{var} == #{n}") when String cg.code("$_[#{k.inspect}] = #{v.inspect} if #{var} == #{n}") else raise("unknown Each type #{v.inspect}") end end end super end |