Class: Turbine::Pipeline::Sender
- Defined in:
- lib/turbine/pipeline/sender.rb
Overview
A segment which transforms its input by sending a message
to each input and returning the result.
( Pump.new([1, 2]) | Sender.new(:to_s) ).to_a
# => ['1', '2']
Each item coming from the source segment must have a public method with the same name as the message
.
Some methods in Turbine return an Array, Collection, or Enumerator as a sort of “result set” – such as Node#in, Node#descendants, etc. In these cases, each element in the result set is yielded separately before continuing with the next input. See Expander for more details.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Attributes inherited from Segment
Instance Method Summary collapse
-
#initialize(message, *args) ⇒ Sender
constructor
Public: Creates a new Sender segment.
-
#to_s ⇒ Object
Public: Describes the segments through which each input will pass.
Methods inherited from Expander
Methods inherited from Segment
#append, #each, #inspect, #next, #rewind, #trace, #tracing=
Constructor Details
#initialize(message, *args) ⇒ Sender
Public: Creates a new Sender segment.
message - The message (method name) to be sent to each value in the
pipeline.
args - Optional arguments to be sent with the message.
Returns a Sender.
26 27 28 29 30 31 |
# File 'lib/turbine/pipeline/sender.rb', line 26 def initialize(, *args) @message = @args = args super() end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
17 18 19 |
# File 'lib/turbine/pipeline/sender.rb', line 17 def args @args end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
17 18 19 |
# File 'lib/turbine/pipeline/sender.rb', line 17 def @message end |
Instance Method Details
#to_s ⇒ Object
Public: Describes the segments through which each input will pass.
Returns a string.
36 37 38 39 |
# File 'lib/turbine/pipeline/sender.rb', line 36 def to_s "#{ source_to_s } | #{ .to_s }" \ "(#{ args.map(&:inspect).join(', ') })" end |