Class: Proc::Composition::Evaluator
- Inherits:
-
Object
- Object
- Proc::Composition::Evaluator
- Defined in:
- lib/proc/composition/evaluator.rb
Instance Attribute Summary collapse
-
#callables ⇒ Object
readonly
Returns the value of attribute callables.
Instance Method Summary collapse
- #<<(proc) ⇒ Object
- #>>(other) ⇒ Object
- #[](proc) ⇒ Object
- #call(**arguments) ⇒ Object
-
#initialize ⇒ Evaluator
constructor
A new instance of Evaluator.
- #initialize_copy(_) ⇒ Object
- #serialize ⇒ Object
Constructor Details
#initialize ⇒ Evaluator
8 9 10 |
# File 'lib/proc/composition/evaluator.rb', line 8 def initialize @callables = [] end |
Instance Attribute Details
#callables ⇒ Object (readonly)
Returns the value of attribute callables.
6 7 8 |
# File 'lib/proc/composition/evaluator.rb', line 6 def callables @callables end |
Instance Method Details
#<<(proc) ⇒ Object
22 23 24 |
# File 'lib/proc/composition/evaluator.rb', line 22 def <<(proc) @callables << proc end |
#>>(other) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/proc/composition/evaluator.rb', line 26 def >>(other) evaluator = dup case other when Evaluator other.callables.each do |each_callable| evaluator << each_callable end when Callable evaluator << Deferable.new(other.proc) end evaluator end |
#[](proc) ⇒ Object
16 17 18 19 20 |
# File 'lib/proc/composition/evaluator.rb', line 16 def [](proc) evaluator = dup evaluator << Deferable.new(proc) evaluator end |
#call(**arguments) ⇒ Object
41 42 43 44 45 |
# File 'lib/proc/composition/evaluator.rb', line 41 def call(**arguments) evaluator = dup evaluator.callables.last.arguments = arguments evaluator end |
#initialize_copy(_) ⇒ Object
12 13 14 |
# File 'lib/proc/composition/evaluator.rb', line 12 def initialize_copy(_) @callables = @callables.map(&:dup) end |
#serialize ⇒ Object
47 48 49 |
# File 'lib/proc/composition/evaluator.rb', line 47 def serialize @callables.map(&:serialize) end |