Class: Functionalist::PointFree::Expression
- Inherits:
-
Object
- Object
- Functionalist::PointFree::Expression
show all
- Defined in:
- lib/functionalist/point_free/expression.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Expression.
8
9
10
|
# File 'lib/functionalist/point_free/expression.rb', line 8
def initialize
@methods = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*method_and_args, &block) ⇒ Object
17
18
19
20
|
# File 'lib/functionalist/point_free/expression.rb', line 17
def method_missing(*method_and_args, &block)
@methods << [method_and_args, block] unless method_and_args == [:respond_to?, :to_proc]
self
end
|
Instance Method Details
#queue ⇒ Object
32
33
34
|
# File 'lib/functionalist/point_free/expression.rb', line 32
def queue
@methods
end
|
#to_proc ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/functionalist/point_free/expression.rb', line 23
def to_proc
lambda do |obj|
reciever, value = @methods.inject(obj) do |left, right|
Functionalist::PointFree::Operator.caculate(left, right)
end
reciever
end
end
|