Class: Rmk::Rule
- Inherits:
-
Object
- Object
- Rmk::Rule
- Defined in:
- lib/rmk/rule.rb
Defined Under Namespace
Classes: Var
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#[]=(name, append = false, value) ⇒ Object
add var define template.
- #apply_to(tgt) ⇒ Object
-
#initialize(command) ⇒ Rule
constructor
create Rule.
- #vars ⇒ Object
Constructor Details
#initialize(command) ⇒ Rule
create Rule
8 9 10 11 12 |
# File 'lib/rmk/rule.rb', line 8 def initialize(command) @command = command @vars = {} @rmk_vars = {'out'=>nil, 'collection'=>nil} end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
13 14 15 |
# File 'lib/rmk/rule.rb', line 13 def command @command end |
Instance Method Details
#[](name) ⇒ Object
17 |
# File 'lib/rmk/rule.rb', line 17 def [](name) @rmk_vars[name] end |
#[]=(name, append = false, value) ⇒ Object
add var define template
21 22 23 24 25 |
# File 'lib/rmk/rule.rb', line 21 def []=(name, append = false, value) return @vars[name] = Var.new(append, value) unless @rmk_vars.include? name raise "special var '#{name}' can't be append" if append @rmk_vars[name] = value end |
#apply_to(tgt) ⇒ Object
27 28 29 |
# File 'lib/rmk/rule.rb', line 27 def apply_to(tgt) @vars.each{|name, var| var.append? ? tgt[name] += var.value : tgt[name] = var.value } end |
#vars ⇒ Object
15 |
# File 'lib/rmk/rule.rb', line 15 def vars; self end |