Module: Dogy

Defined in:
lib/dogy.rb,
lib/dogy/dogylib.rb,
lib/dogy/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.eat(args, location) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/dogy/dogylib.rb', line 23

def self.eat(args,location)
  result = []
  parse(args,location).each do |m|
    m[:args].map!{|v| eval(v)}
    result << m[:method].call(*m[:args])
  end
  result
end

.parse(args, location) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dogy/dogylib.rb', line 3

def self.parse(args,location)
  list = []
  m = nil
  args.each do |arg|
    if !m && location.private_methods.include?(arg.to_sym)
      method = location.method(arg.to_sym)
      m = {
        :method => method,
        :size => method.parameters.length,
        :args => []
      }
      list << m
    elsif m
      m[:args] << arg if m[:args].length < m[:size]
    end
  end
  list
end