Class: StatusPageRuby::Status
- Inherits:
-
Object
- Object
- StatusPageRuby::Status
- 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
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #down? ⇒ Boolean
- #history_record ⇒ Object
-
#initialize(service, state, status, time) ⇒ Status
constructor
A new instance of Status.
- #record ⇒ Object
- #to_csv ⇒ Object
- #up? ⇒ Boolean
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
#service ⇒ Object (readonly)
Returns the value of attribute service.
7 8 9 |
# File 'lib/status_page_ruby/status.rb', line 7 def service @service end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/status_page_ruby/status.rb', line 7 def state @state end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/status_page_ruby/status.rb', line 7 def status @status end |
#time ⇒ Object (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
20 21 22 |
# File 'lib/status_page_ruby/status.rb', line 20 def down? state == DOWN_STATE end |
#history_record ⇒ Object
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 |
#record ⇒ Object
28 29 30 |
# File 'lib/status_page_ruby/status.rb', line 28 def record [service, state, status, time] end |
#to_csv ⇒ Object
32 33 34 |
# File 'lib/status_page_ruby/status.rb', line 32 def to_csv record.to_csv end |
#up? ⇒ Boolean
16 17 18 |
# File 'lib/status_page_ruby/status.rb', line 16 def up? state == UP_STATE end |