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.
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.
26 27 28 29 |
# File 'lib/transproc/function.rb', line 26 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
23 24 25 |
# File 'lib/transproc/function.rb', line 23 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
16 17 18 |
# File 'lib/transproc/function.rb', line 16 def fn @fn end |
Instance Method Details
#call(*value) ⇒ Object Also known as: []
Call the wrapped proc
38 39 40 41 42 |
# File 'lib/transproc/function.rb', line 38 def call(*value) fn[*value, *args] rescue => ex raise MalformedInputError.new(@fn, value, ex) end |
#compose(other) ⇒ Composite Also known as: +, >>
Compose this function with another function or a proc
54 55 56 |
# File 'lib/transproc/function.rb', line 54 def compose(other) Composite.new(self, other) end |
#to_ast ⇒ Array
Return a simple AST representation of this function
65 66 67 68 |
# File 'lib/transproc/function.rb', line 65 def to_ast identifier = fn.is_a?(::Proc) ? fn : fn.name [identifier, args] end |