Class: Mayak::Function
- Inherits:
-
Object
- Object
- Mayak::Function
- Extended by:
- T::Generic, T::Helpers, T::Sig
- Defined in:
- lib/mayak/function.rb
Constant Summary collapse
- Input =
type_member
- Output =
type_member
Instance Attribute Summary collapse
-
#blk ⇒ Object
readonly
Returns the value of attribute blk.
Class Method Summary collapse
Instance Method Summary collapse
- #and_then(another) ⇒ Object (also: #>>)
- #call(input) ⇒ Object
- #compose(another) ⇒ Object (also: #<<)
-
#initialize(&blk) ⇒ Function
constructor
A new instance of Function.
- #to_proc ⇒ Object
Constructor Details
Instance Attribute Details
#blk ⇒ Object (readonly)
Returns the value of attribute blk.
14 15 16 |
# File 'lib/mayak/function.rb', line 14 def blk @blk end |
Class Method Details
Instance Method Details
#and_then(another) ⇒ Object Also known as: >>
50 51 52 |
# File 'lib/mayak/function.rb', line 50 def and_then(another) Mayak::Function[Input, T.type_parameter(:Output2)].new { |a| another.call(blk.call(a)) } end |
#call(input) ⇒ Object
41 42 43 |
# File 'lib/mayak/function.rb', line 41 def call(input) blk.call(input) end |
#compose(another) ⇒ Object Also known as: <<
60 61 62 |
# File 'lib/mayak/function.rb', line 60 def compose(another) Mayak::Function[T.type_parameter(:Input2), Output].new { |a| blk.call(another.call(a)) } end |
#to_proc ⇒ Object
36 37 38 |
# File 'lib/mayak/function.rb', line 36 def to_proc -> (input) { call(input) } end |