Class: Co2Notify::Status::Normal

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

Instance Attribute Summary

Attributes inherited from Base

#co2, #config, #previous, #time

Instance Method Summary collapse

Methods inherited from Base

#initialize, #type_changed?

Constructor Details

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

Instance Method Details

#changed?(new_status) ⇒ Boolean

Returns:

  • (Boolean)


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

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



75
76
77
# File 'lib/co2-notify/status.rb', line 75

def color
  :green
end

#messageObject



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

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

#timeoutObject



86
87
88
# File 'lib/co2-notify/status.rb', line 86

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