Class: PipelineToolkit::MessageSink

Inherits:
Object
  • Object
show all
Includes:
MessageCommand
Defined in:
lib/pipeline_toolkit/message_sink.rb

Instance Attribute Summary

Attributes included from MessageCommand

#options

Instance Method Summary collapse

Methods included from MessageCommand

#acknowledge, #cleanup, #description, #initialize, #initialize_machine, #pass_on, #process, #process_system, #send_description, #start, #stop, #write_to_pipe

Instance Method Details

#format_message(message) ⇒ Object

Sort key order



15
16
17
18
19
20
21
22
23
# File 'lib/pipeline_toolkit/message_sink.rb', line 15

def format_message(message)
  message = message.sort { |a, b| a[0].to_s <=> b[0].to_s }
  str = "{"
  message.each_with_index do |item, i|
    str << "#{item[0].inspect}:#{item[1].inspect}"
    str << ", " unless i+1 >= message.size
  end
  str << "}"
end

#process_standard(message) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/pipeline_toolkit/message_sink.rb', line 6

def process_standard(message)
  if @options[:out]
    $stdout.puts(format_message(message))
    $stdout.flush
  end
  acknowledge(message)
end