Class: ConsMethod
- Inherits:
-
Object
- Object
- ConsMethod
- Defined in:
- lib/method_missing/cons_method.rb
Instance Method Summary collapse
- #*(h) ⇒ Object
- #/(h) ⇒ Object
- #[](*x) ⇒ Object
- #^(n) ⇒ Object
- #arity ⇒ Object
- #call(x) ⇒ Object
-
#initialize(f, g) ⇒ ConsMethod
constructor
A new instance of ConsMethod.
- #inspect ⇒ Object
- #owner ⇒ Object
- #receiver ⇒ Object
- #to_proc ⇒ Object
Constructor Details
#initialize(f, g) ⇒ ConsMethod
Returns a new instance of ConsMethod.
4 5 6 7 |
# File 'lib/method_missing/cons_method.rb', line 4 def initialize(f,g) @f = f @g = g end |
Instance Method Details
#*(h) ⇒ Object
9 10 11 |
# File 'lib/method_missing/cons_method.rb', line 9 def *(h) ConsMethod.new(self, h) end |
#/(h) ⇒ Object
13 14 15 |
# File 'lib/method_missing/cons_method.rb', line 13 def /(h) ApMethod.new([@f, @g, h]) end |
#[](*x) ⇒ Object
50 51 52 |
# File 'lib/method_missing/cons_method.rb', line 50 def [](*x) call(*x) end |
#^(n) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/method_missing/cons_method.rb', line 17 def ^(n) if n < 2 self else ConsMethod.new(self, self ^ (n-1)) end end |
#arity ⇒ Object
42 43 44 |
# File 'lib/method_missing/cons_method.rb', line 42 def arity @g.arity end |
#call(x) ⇒ Object
46 47 48 |
# File 'lib/method_missing/cons_method.rb', line 46 def call(x) @f.call(*@g.call(*x)) end |
#inspect ⇒ Object
38 39 40 |
# File 'lib/method_missing/cons_method.rb', line 38 def inspect "#<ConsMethod: #{@f.inspect} * #{@g.inspect}>" end |
#owner ⇒ Object
26 27 28 |
# File 'lib/method_missing/cons_method.rb', line 26 def owner @g.owner end |
#receiver ⇒ Object
30 31 32 |
# File 'lib/method_missing/cons_method.rb', line 30 def receiver @g.receiver end |
#to_proc ⇒ Object
34 35 36 |
# File 'lib/method_missing/cons_method.rb', line 34 def to_proc Proc.new {|x| @f.call(*@g.call(*x)) } end |