Class: QueueDispatcher::RcAndMsg
- Inherits:
-
Object
- Object
- QueueDispatcher::RcAndMsg
- Defined in:
- lib/queue_dispatcher/rc_and_msg.rb
Instance Attribute Summary collapse
-
#error_msg ⇒ Object
Returns the value of attribute error_msg.
-
#output ⇒ Object
Returns the value of attribute output.
-
#rc ⇒ Object
Returns the value of attribute rc.
Class Method Summary collapse
Instance Method Summary collapse
-
#+(other) ⇒ Object
Addition.
-
#bad_rc(error_msg = '', args = {}) ⇒ Object
Fake a bad RC.
-
#good_rc(output = '', args = {}) ⇒ Object
Fake a good RC.
-
#initialize(args = {}) ⇒ RcAndMsg
constructor
Initializer.
-
#to_hash ⇒ Object
Return hash.
Constructor Details
#initialize(args = {}) ⇒ RcAndMsg
Initializer
19 20 21 22 23 24 |
# 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 |
Instance Attribute Details
#error_msg ⇒ Object
Returns the value of attribute error_msg.
3 4 5 |
# File 'lib/queue_dispatcher/rc_and_msg.rb', line 3 def error_msg @error_msg end |
#output ⇒ Object
Returns the value of attribute output.
3 4 5 |
# File 'lib/queue_dispatcher/rc_and_msg.rb', line 3 def output @output end |
#rc ⇒ Object
Returns the value of attribute rc.
3 4 5 |
# File 'lib/queue_dispatcher/rc_and_msg.rb', line 3 def rc @rc end |
Class Method Details
.bad_rc(error_msg, args = {}) ⇒ Object
12 13 14 15 |
# 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 = {}) ⇒ Object
6 7 8 9 |
# 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 |
Instance Method Details
#+(other) ⇒ Object
Addition
46 47 48 49 50 51 52 |
# 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 = {}) ⇒ Object
Fake a bad RC
37 38 39 40 41 42 |
# 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 = {}) ⇒ Object
Fake a good RC
28 29 30 31 32 33 |
# 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 ⇒ Object
Return hash
56 57 58 |
# File 'lib/queue_dispatcher/rc_and_msg.rb', line 56 def to_hash { :rc => @rc, :output => @output, :error_msg => @error_msg } end |