Class: Transproc::Function Private
- Inherits:
-
Object
- Object
- Transproc::Function
- Defined in:
- lib/transproc/function.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Transformation proc wrapper allowing composition of multiple procs into a data-transformation pipeline.
This is used by Transproc to wrap registered methods.
Direct Known Subclasses
Defined Under Namespace
Classes: Composite
Instance Attribute Summary collapse
-
#args ⇒ Array
readonly
private
Additional arguments that will be passed to the wrapped proc.
-
#fn ⇒ Proc, Composed
readonly
private
Wrapped proc or another composite function.
Instance Method Summary collapse
-
#call(value) ⇒ Object
(also: #[])
Call the wrapped proc.
-
#compose(other) ⇒ Composite
(also: #+, #>>)
Compose this function with another function or a proc.
-
#initialize(fn, options = {}) ⇒ Function
constructor
private
A new instance of Function.
-
#to_ast ⇒ Array
Return a simple AST representation of this function.
Constructor Details
#initialize(fn, options = {}) ⇒ Function
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Function.
24 25 26 27 |
# File 'lib/transproc/function.rb', line 24 def initialize(fn, = {}) @fn = fn @args = .fetch(:args) { [] } end |
Instance Attribute Details
#args ⇒ Array (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Additional arguments that will be passed to the wrapped proc
21 22 23 |
# File 'lib/transproc/function.rb', line 21 def args @args end |
#fn ⇒ Proc, Composed (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wrapped proc or another composite function
14 15 16 |
# File 'lib/transproc/function.rb', line 14 def fn @fn end |
Instance Method Details
#call(value) ⇒ Object Also known as: []
Call the wrapped proc
36 37 38 |
# File 'lib/transproc/function.rb', line 36 def call(value) fn[value, *args] end |
#compose(other) ⇒ Composite Also known as: +, >>
Compose this function with another function or a proc
50 51 52 |
# File 'lib/transproc/function.rb', line 50 def compose(other) Composite.new(self, right: other) end |
#to_ast ⇒ Array
Return a simple AST representation of this function
61 62 63 64 |
# File 'lib/transproc/function.rb', line 61 def to_ast identifier = Proc === fn ? fn : fn.name [identifier, args] end |