Class: Transproc::Function
- Inherits:
-
Object
- Object
- Transproc::Function
- Defined in:
- lib/transproc/function.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#fn ⇒ Object
readonly
Returns the value of attribute fn.
Instance Method Summary collapse
- #call(value) ⇒ Object (also: #[])
- #compose(other) ⇒ Object (also: #+)
-
#initialize(fn, args = []) ⇒ Function
constructor
A new instance of Function.
Constructor Details
#initialize(fn, args = []) ⇒ Function
Returns a new instance of Function.
5 6 7 8 |
# File 'lib/transproc/function.rb', line 5 def initialize(fn, args = []) @fn = fn @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/transproc/function.rb', line 3 def args @args end |
#fn ⇒ Object (readonly)
Returns the value of attribute fn.
3 4 5 |
# File 'lib/transproc/function.rb', line 3 def fn @fn end |
Instance Method Details
#call(value) ⇒ Object Also known as: []
10 11 12 |
# File 'lib/transproc/function.rb', line 10 def call(value) fn[value, *args] end |
#compose(other) ⇒ Object Also known as: +
15 16 17 |
# File 'lib/transproc/function.rb', line 15 def compose(other) self.class.new(-> *result { other[fn[*result]] }, args) end |