Class: Tnw::ServerMetricStatus
- Inherits:
-
Object
- Object
- Tnw::ServerMetricStatus
- Defined in:
- app/presenters/tnw/server_metric_status.rb
Instance Attribute Summary collapse
-
#sample ⇒ Object
readonly
Returns the value of attribute sample.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(server:, sample:, now: Time.current, configuration: Tnw.configuration) ⇒ ServerMetricStatus
constructor
A new instance of ServerMetricStatus.
- #status ⇒ Object
- #status_label ⇒ Object
Constructor Details
#initialize(server:, sample:, now: Time.current, configuration: Tnw.configuration) ⇒ ServerMetricStatus
Returns a new instance of ServerMetricStatus.
5 6 7 8 9 10 |
# File 'app/presenters/tnw/server_metric_status.rb', line 5 def initialize(server:, sample:, now: Time.current, configuration: Tnw.configuration) @server = server @sample = sample @now = now @configuration = configuration end |
Instance Attribute Details
#sample ⇒ Object (readonly)
Returns the value of attribute sample.
3 4 5 |
# File 'app/presenters/tnw/server_metric_status.rb', line 3 def sample @sample end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
3 4 5 |
# File 'app/presenters/tnw/server_metric_status.rb', line 3 def server @server end |
Instance Method Details
#status ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/presenters/tnw/server_metric_status.rb', line 12 def status return :disabled unless server.enabled? return :rejected if server.last_ingestion_status == "rejected" return :never_received unless sample return :stale if stale? return :partial if sample.parse_errors.any? :healthy end |
#status_label ⇒ Object
22 23 24 |
# File 'app/presenters/tnw/server_metric_status.rb', line 22 def status_label status.to_s.humanize end |