Class: Expedition::Status

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

Constant Summary collapse

SEVERITIES =
{
  'S' => :success,
  'I' => :info,
  'W' => :warn,
  'E' => :error,
  'F' => :fatal
}.freeze
OK_SEVERITIES =
i(success info warn).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ Status



24
25
26
27
28
29
30
31
32
# File 'lib/expedition/status.rb', line 24

def initialize(body)
  status = body ? body.first : {}

  @severity    = SEVERITIES[status['STATUS']]
  @code        = status['Code']
  @message     = status['Msg']
  @description = status['Description']
  @executed_at = Time.at(status['When']) rescue nil
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



16
17
18
# File 'lib/expedition/status.rb', line 16

def code
  @code
end

#descriptionObject (readonly)

Returns the value of attribute description.



20
21
22
# File 'lib/expedition/status.rb', line 20

def description
  @description
end

#executed_atObject (readonly)

Returns the value of attribute executed_at.



22
23
24
# File 'lib/expedition/status.rb', line 22

def executed_at
  @executed_at
end

#messageObject (readonly)

Returns the value of attribute message.



18
19
20
# File 'lib/expedition/status.rb', line 18

def message
  @message
end

#severityObject (readonly)

Returns the value of attribute severity.



14
15
16
# File 'lib/expedition/status.rb', line 14

def severity
  @severity
end

Instance Method Details

#error?Boolean



46
47
48
# File 'lib/expedition/status.rb', line 46

def error?
  severity == :error
end

#fatal?Boolean



50
51
52
# File 'lib/expedition/status.rb', line 50

def fatal?
  severity == :fatal
end

#info?Boolean



38
39
40
# File 'lib/expedition/status.rb', line 38

def info?
  severity == :info
end

#ok?Boolean



54
55
56
# File 'lib/expedition/status.rb', line 54

def ok?
  OK_SEVERITIES.include?(severity)
end

#success?Boolean



34
35
36
# File 'lib/expedition/status.rb', line 34

def success?
  severity == :success
end

#warn?Boolean



42
43
44
# File 'lib/expedition/status.rb', line 42

def warn?
  severity == :warn
end