Class: ConsMethod

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

Instance Method Summary collapse

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

#arityObject



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

#inspectObject



38
39
40
# File 'lib/method_missing/cons_method.rb', line 38

def inspect
  "#<ConsMethod: #{@f.inspect} * #{@g.inspect}>"
end

#ownerObject



26
27
28
# File 'lib/method_missing/cons_method.rb', line 26

def owner
  @g.owner
end

#receiverObject



30
31
32
# File 'lib/method_missing/cons_method.rb', line 30

def receiver
  @g.receiver
end

#to_procObject



34
35
36
# File 'lib/method_missing/cons_method.rb', line 34

def to_proc
  Proc.new {|x| @f.call(*@g.call(*x)) }
end