class Rmk::Rule

Constants

Var

Attributes

command[R]

Public Class Methods

new(command) click to toggle source

create Rule @param command [String] exec command template

# File lib/rmk/rule.rb, line 8
def initialize(command)
        @command = command
        @vars = {}
        @rmk_vars = {'out'=>nil, 'collection'=>nil}
end

Public Instance Methods

[](name) click to toggle source
# File lib/rmk/rule.rb, line 17
def [](name) @rmk_vars[name] end
[]=(name, append = false, value) click to toggle source

add var define template @return Array<Var>

# 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) click to toggle source
# 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() click to toggle source
# File lib/rmk/rule.rb, line 15
def vars; self end