Class: Fbp::Assign_node
Overview
Description
The Assign_node will take its incoming IPs and add items to the hash before passing it one to its down stream node(s)
Discussion
The Assign_node takes an optional IIP of the form {:additional_args =>{}}
The hash contains the items that will be added to every incoming IP sent to this node. The IIP is optional with this node. If no additional arguments are given to this node then it will simply write all of its in coming IPs to its output.
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#do_node_work(args) ⇒ Object
If an IIP has set the :additional_args key in options, then those items will be appended to every incoming IP.
-
#initialize(additional_args = nil) ⇒ Assign_node
constructor
When creating a new Assign_node instance one can optionally provide a hash containing the items to be added to every in coming IP.
Methods inherited from Node
#clean_option, #execute, #is_ready_to_run?, #merge_options!, #register_for_output_from_node, #set_option, #stop, #unregister_for_output_from_node, #wait_until_completed, #write_to_input, #write_to_output
Constructor Details
#initialize(additional_args = nil) ⇒ Assign_node
When creating a new Assign_node instance one can optionally provide a hash containing the items to be added to every in coming IP
21 22 23 24 |
# File 'lib/fbp/assign-node.rb', line 21 def initialize(additional_args = nil) super() [:additional_args] = additional_args if !additional_args.nil? end |
Instance Method Details
#do_node_work(args) ⇒ Object
If an IIP has set the :additional_args key in options, then those items will be appended to every incoming IP. If the :additional_args key has not been set then the IP will be passed downstream untouched.
If the IP has an :ips key then each of those IP in the array of IPs will be modified as described above.
34 35 36 37 38 |
# File 'lib/fbp/assign-node.rb', line 34 def do_node_work(args) ips = args.has_key? :ips ? args[:ips] : [args] ips.each {|ip| ip.merge!([:additional_args]) if .has_key? :additional_args} super(args) end |