Class: Expeditor::Status
- Inherits:
-
Object
- Object
- Expeditor::Status
- Defined in:
- lib/expeditor/status.rb
Overview
Thread unsafe.
Instance Attribute Summary collapse
-
#break ⇒ Object
readonly
Returns the value of attribute break.
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#failure ⇒ Object
readonly
Returns the value of attribute failure.
-
#rejection ⇒ Object
readonly
Returns the value of attribute rejection.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
- #increment(type, i = 1) ⇒ Object
-
#initialize ⇒ Status
constructor
A new instance of Status.
- #merge!(other) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize ⇒ Status
Returns a new instance of Status.
11 12 13 |
# File 'lib/expeditor/status.rb', line 11 def initialize set(0, 0, 0, 0, 0, 0) end |
Instance Attribute Details
#break ⇒ Object (readonly)
Returns the value of attribute break.
8 9 10 |
# File 'lib/expeditor/status.rb', line 8 def break @break end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
9 10 11 |
# File 'lib/expeditor/status.rb', line 9 def dependency @dependency end |
#failure ⇒ Object (readonly)
Returns the value of attribute failure.
5 6 7 |
# File 'lib/expeditor/status.rb', line 5 def failure @failure end |
#rejection ⇒ Object (readonly)
Returns the value of attribute rejection.
6 7 8 |
# File 'lib/expeditor/status.rb', line 6 def rejection @rejection end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
4 5 6 |
# File 'lib/expeditor/status.rb', line 4 def success @success end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
7 8 9 |
# File 'lib/expeditor/status.rb', line 7 def timeout @timeout end |
Instance Method Details
#increment(type, i = 1) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/expeditor/status.rb', line 15 def increment(type, i = 1) case type when :success @success += i when :failure @failure += i when :rejection @rejection += i when :timeout @timeout += i when :break @break += i when :dependency @dependency += i else raise ArgumentError.new("Unknown type: #{type}") end end |
#merge!(other) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/expeditor/status.rb', line 34 def merge!(other) increment(:success, other.success) increment(:failure, other.failure) increment(:rejection, other.rejection) increment(:timeout, other.timeout) increment(:break, other.break) increment(:dependency, other.dependency) self end |
#reset ⇒ Object
44 45 46 |
# File 'lib/expeditor/status.rb', line 44 def reset set(0, 0, 0, 0, 0, 0) end |