Class: Expeditor::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/expeditor/status.rb

Overview

Thread unsafe.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStatus

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

#breakObject (readonly)

Returns the value of attribute break.



8
9
10
# File 'lib/expeditor/status.rb', line 8

def break
  @break
end

#dependencyObject (readonly)

Returns the value of attribute dependency.



9
10
11
# File 'lib/expeditor/status.rb', line 9

def dependency
  @dependency
end

#failureObject (readonly)

Returns the value of attribute failure.



5
6
7
# File 'lib/expeditor/status.rb', line 5

def failure
  @failure
end

#rejectionObject (readonly)

Returns the value of attribute rejection.



6
7
8
# File 'lib/expeditor/status.rb', line 6

def rejection
  @rejection
end

#successObject (readonly)

Returns the value of attribute success.



4
5
6
# File 'lib/expeditor/status.rb', line 4

def success
  @success
end

#timeoutObject (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

#resetObject



44
45
46
# File 'lib/expeditor/status.rb', line 44

def reset
  set(0, 0, 0, 0, 0, 0)
end