class QueueDispatcher::RcAndMsg

Attributes

error_msg[RW]
output[RW]
rc[RW]

Public Class Methods

bad_rc(error_msg, args = {}) click to toggle source
# File lib/queue_dispatcher/rc_and_msg.rb, line 12
def self.bad_rc(error_msg, args = {})
  rc_and_msg = new
  rc_and_msg.bad_rc(error_msg, args)
end
good_rc(output = '', args = {}) click to toggle source
# File lib/queue_dispatcher/rc_and_msg.rb, line 6
def self.good_rc(output = '', args = {})
  rc_and_msg = new
  rc_and_msg.good_rc(output, args)
end
new(args = {}) click to toggle source

Initializer

# File lib/queue_dispatcher/rc_and_msg.rb, line 19
def initialize(args = {})
  @rc = args[:rc].to_i if args[:rc]
  @output = args[:output]
  @error_msg = args[:error_msg]
  self
end

Public Instance Methods

+(other) click to toggle source

Addition

# File lib/queue_dispatcher/rc_and_msg.rb, line 46
def +(other)
  rc_and_msg = self.clone
  rc_and_msg.rc += other.rc
  rc_and_msg.output = rc_and_msg.output ? "#{output}\n#{other.output}" : other.output if other.output.present?
  rc_and_msg.error_msg = rc_and_msg.error_msg ? "#{error_msg}\n#{other.error_msg}" : other.error_msg if other.error_msg.present?
  rc_and_msg
end
bad_rc(error_msg = '', args = {}) click to toggle source

Fake a bad RC

# File lib/queue_dispatcher/rc_and_msg.rb, line 37
def bad_rc(error_msg = '', args = {})
  @rc = 999
  @output = args[:output]
  @error_msg = error_msg
  self
end
good_rc(output = '', args = {}) click to toggle source

Fake a good RC

# File lib/queue_dispatcher/rc_and_msg.rb, line 28
def good_rc(output = '', args = {})
  @rc = 0
  @output = output
  @error_msg = args[:error_msg]
  self
end
to_hash() click to toggle source

Return hash

# File lib/queue_dispatcher/rc_and_msg.rb, line 56
def to_hash
  { :rc => @rc, :output => @output, :error_msg => @error_msg }
end