Class: ApMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/method_missing/ap_method.rb

Instance Method Summary collapse

Constructor Details

#initialize(methods) ⇒ ApMethod

Returns a new instance of ApMethod.



4
5
6
# File 'lib/method_missing/ap_method.rb', line 4

def initialize(methods)
  @methods = methods
end

Instance Method Details

#*(f) ⇒ Object



8
9
10
# File 'lib/method_missing/ap_method.rb', line 8

def *(f)
  ApMethod.new(@methods.map {|m| ConsMethod.new(m, f)})
end

#/(f) ⇒ Object



12
13
14
# File 'lib/method_missing/ap_method.rb', line 12

def /(f)
  ApMethod.new(@methods + [f])
end

#[](*x) ⇒ Object



39
40
41
# File 'lib/method_missing/ap_method.rb', line 39

def [](*x)
  call(*x)
end

#^(power) ⇒ Object



16
17
18
# File 'lib/method_missing/ap_method.rb', line 16

def ^(power)
  ApMethod.new(@methods.map {|m| m ^ power})
end

#arityObject



35
36
37
# File 'lib/method_missing/ap_method.rb', line 35

def arity
  @methods.first.arity
end

#call(*x) ⇒ Object



21
22
23
# File 'lib/method_missing/ap_method.rb', line 21

def call(*x)
  @methods.map{|m| m.call(*x)}
end

#inspectObject



31
32
33
# File 'lib/method_missing/ap_method.rb', line 31

def inspect
  "#<ApMethod: #{@methods.map{|m| m.inspect}.join(' / ')}>"
end

#to_procObject



25
26
27
28
29
# File 'lib/method_missing/ap_method.rb', line 25

def to_proc
  lambda {|*x|
    @methods.map {|m| m.call(*x) }
  }
end