Class: StatusPageRuby::Status

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

Constant Summary collapse

HISTORY_RECORD_TIME_FORMAT =
'%d.%m.%Y %H:%M:%S'.freeze
UP_STATE =
'up'.freeze
DOWN_STATE =
'down'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service, state, status, time) ⇒ Status

Returns a new instance of Status.



9
10
11
12
13
14
# File 'lib/status_page_ruby/status.rb', line 9

def initialize(service, state, status, time)
  @service = service.to_s
  @state = state.to_s
  @status = status.to_s
  @time = time.to_s
end

Instance Attribute Details

#serviceObject (readonly)

Returns the value of attribute service.



7
8
9
# File 'lib/status_page_ruby/status.rb', line 7

def service
  @service
end

#stateObject (readonly)

Returns the value of attribute state.



7
8
9
# File 'lib/status_page_ruby/status.rb', line 7

def state
  @state
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/status_page_ruby/status.rb', line 7

def status
  @status
end

#timeObject (readonly)

Returns the value of attribute time.



7
8
9
# File 'lib/status_page_ruby/status.rb', line 7

def time
  @time
end

Instance Method Details

#down?Boolean

Returns:

  • (Boolean)


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

def down?
  state == DOWN_STATE
end

#history_recordObject



24
25
26
# File 'lib/status_page_ruby/status.rb', line 24

def history_record
  [service, state, Time.at(time.to_i).utc.strftime(HISTORY_RECORD_TIME_FORMAT)]
end

#recordObject



28
29
30
# File 'lib/status_page_ruby/status.rb', line 28

def record
  [service, state, status, time]
end

#to_csvObject



32
33
34
# File 'lib/status_page_ruby/status.rb', line 32

def to_csv
  record.to_csv
end

#up?Boolean

Returns:

  • (Boolean)


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

def up?
  state == UP_STATE
end