Class: Fbp::Concatenate_node
Overview
Description
The Concatenate_node takes a list of keys as it IIP and as IPs are sent to this node, it will check to see if th IP has any of the keys specified in the IIP. If there is a match then the IP is merged into a single IP. Once all of the keys that are specified in the IIP are in the merged IP, it is sent to the down stream node.
An example of the usage of this node would be if the down stream node was an encryption node. The encryption node might require an IIP with keys of key_data, salt, mode, and padding. This concatenate node could be used to gather all of that dat into an IIP to send to the encryption node.
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#do_node_work(args) ⇒ Object
This will do the work of determining if all of the required data has been acquired before creating an IP to send down stream.
-
#initialize(keys = nil) ⇒ Concatenate_node
constructor
When creating a new Concatenate_node instance one can provide an array of keys that will be used to determine if all of the necessary data has been cached before creating a new IP to send down stream.
-
#is_ready_to_run? ⇒ Boolean
This is called to see if this node has been parameterized with the required keys needed for this node to do its work.
Methods inherited from Node
#clean_option, #execute, #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(keys = nil) ⇒ Concatenate_node
When creating a new Concatenate_node instance one can provide an array of keys that will be used to determine if all of the necessary data has been cached before creating a new IP to send down stream.
25 26 27 28 29 |
# File 'lib/fbp/concatenate-node.rb', line 25 def initialize(keys = nil) super() [:keys] = keys if !keys.nil? @output_ip = Hash.new end |
Instance Method Details
#do_node_work(args) ⇒ Object
This will do the work of determining if all of the required data has been acquired before creating an IP to send down stream.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fbp/concatenate-node.rb', line 43 def do_node_work(args) # Merge the IP into Concatenate_node the output hash ips = nil if args.has_key? :ips ips = args[:ips] temp = args.clone temp.delete(:ips) ips << temp if !temp.empty? else ips = [args] end ips.each {|ip| @output_ip.merge!(ip)} # Check to see if the output_ip hash has all of the required keys. # If it does, then write the output_ip hash to the output queue if [:keys] == ([:keys] & @output_ip.keys) write_to_output(@output_ip) @output_ip.clear end true end |
#is_ready_to_run? ⇒ Boolean
This is called to see if this node has been parameterized with the required keys needed for this node to do its work
35 36 37 |
# File 'lib/fbp/concatenate-node.rb', line 35 def is_ready_to_run? .has_key? :keys end |