Class: Lab42::Function
- Inherits:
-
Object
- Object
- Lab42::Function
- Extended by:
- Constructors
- Defined in:
- lib/lab42/function.rb,
lib/lab42/function/version.rb,
lib/lab42/function/constructors.rb,
lib/lab42/function/make_function.rb
Overview
Implementation of the isolated functional behavior
- Partials
- Chaining
Defined Under Namespace
Modules: Constructors, MakeFunction, My, ParamsReorderer Classes: Placeholder
Constant Summary collapse
- VERSION =
'0.1.1'
Constants included from Constructors
Instance Attribute Summary collapse
-
#arity ⇒ Object
readonly
Returns the value of attribute arity.
-
#behavior ⇒ Object
readonly
Returns the value of attribute behavior.
Instance Method Summary collapse
- #call(*second_stage_params) ⇒ Object
-
#initialize(behavior, arity = -1) ⇒ Function
constructor
A new instance of Function.
- #|(rhs) ⇒ Object
Methods included from Constructors
a1, a2, a3, constant, force_pipe, free_receiver, partial, placeholder
Constructor Details
#initialize(behavior, arity = -1) ⇒ Function
Returns a new instance of Function.
28 29 30 31 |
# File 'lib/lab42/function.rb', line 28 def initialize behavior, arity=-1 @behavior = behavior @arity = arity end |
Instance Attribute Details
#arity ⇒ Object (readonly)
Returns the value of attribute arity.
18 19 20 |
# File 'lib/lab42/function.rb', line 18 def arity @arity end |
#behavior ⇒ Object (readonly)
Returns the value of attribute behavior.
18 19 20 |
# File 'lib/lab42/function.rb', line 18 def behavior @behavior end |
Instance Method Details
#call(*second_stage_params) ⇒ Object
33 34 35 |
# File 'lib/lab42/function.rb', line 33 def call *second_stage_params behavior.(*second_stage_params) end |
#|(rhs) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/lab42/function.rb', line 20 def | rhs return call if rhs == self.class.force_pipe rhs = MakeFunction.make_function rhs self.class.new ->{ rhs.call(self.call) } end |