Class: Co2Notify::Status::High

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)


54
55
56
57
58
59
# File 'lib/co2-notify/status.rb', line 54

def changed?(new_status)
  new_status.is_a?(Empty) ||
    new_status.is_a?(Normal) ||
    (new_status.is_a?(High) && new_status.co2 > co2)  ||
    new_status.is_a?(VeryHigh)
end

#colorObject



50
51
52
# File 'lib/co2-notify/status.rb', line 50

def color
  previous.is_a?(High) ? :red : :yellow
end

#messageObject



46
47
48
# File 'lib/co2-notify/status.rb', line 46

def message
  "#{hc_mention}CO₂ level is high - #{co2}. Please open the windows!"
end

#timeoutObject



61
62
63
# File 'lib/co2-notify/status.rb', line 61

def timeout
  previous.is_a?(Empty) || previous.is_a?(Normal) ? cooldown : super
end