Class: Co2Notify::Status::Normal

Inherits:
Base
  • Object
show all
Defined in:
lib/co2-notify/status.rb

Constant Summary

Constants inherited from Base

Base::SAFE_RANGE

Instance Attribute Summary

Attributes inherited from Base

#co2, #config, #previous, #time

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Co2Notify::Status::Base

Instance Method Details

#changed?(new_status) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
80
81
82
# File 'lib/co2-notify/status.rb', line 77

def changed?(new_status)
  new_status.is_a?(Empty) ||
    new_status.is_a?(High) ||
    new_status.is_a?(VeryHigh) ||
    (new_status.is_a?(Normal) && new_status.time >= time + ping_timeout * 60)
end

#colorObject



73
74
75
# File 'lib/co2-notify/status.rb', line 73

def color
  :green
end

#messageObject



65
66
67
68
69
70
71
# File 'lib/co2-notify/status.rb', line 65

def message
  if previous.is_a?(Normal) || previous.is_a?(Empty)
    "CO₂ level is normal - #{co2}."
  else
    "#{hc_mention}CO₂ level is normalized - #{co2}."
  end
end

#timeoutObject



84
85
86
# File 'lib/co2-notify/status.rb', line 84

def timeout
  previous.is_a?(High) || previous.is_a?(VeryHigh) ? cooldown : super
end