module Boxomojo::Mod
Attributes
kv[R]
meta[R]
stack[R]
Public Class Methods
new(name=nil, *args)
click to toggle source
# File lib/boxomojo.rb, line 8 def initialize name=nil, *args @stack = [] @kv = {} @meta = {:name=>name, :args=>args} run(&Proc.new) if block_given? end
Public Instance Methods
args()
click to toggle source
# File lib/boxomojo.rb, line 19 def args @meta[:args] end
collect(key, arr)
click to toggle source
# File lib/boxomojo.rb, line 44 def collect key, arr if !@kv.has_key?(key) @kv[key] = [] end @kv[key].concat arr arr end
name()
click to toggle source
# File lib/boxomojo.rb, line 15 def name @meta[:name] end
new_box(name, *args)
click to toggle source
# File lib/boxomojo.rb, line 27 def new_box name, *args box = self.class.new(name, *args) if block_given? box.run(&(Proc.new)) end @stack.<<( box ) end
push(*args)
click to toggle source
# File lib/boxomojo.rb, line 23 def push *args stack.concat args end
run(&blok)
click to toggle source
# File lib/boxomojo.rb, line 53 def run &blok instance_eval &blok self end
update(key, arr)
click to toggle source
# File lib/boxomojo.rb, line 35 def update key, arr if arr.size == 1 || arr.empty? @kv[key] = arr.first else @kv[key] = arr end arr end