Class: Co2Notify::Status

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

Defined Under Namespace

Classes: Base, Empty, High, Normal, VeryHigh

Class Method Summary collapse

Class Method Details

.build(co2, time, config, previous = nil) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/co2-notify/status.rb', line 108

def self.build(co2, time, config, previous = nil)
  case co2
  when 1..config.high_level
    Normal.new(config, time, previous, co2)
  when config.high_level..config.very_high_level
    High.new(config, time, previous, co2)
  when proc { |n| n >= config.very_high_level }
    VeryHigh.new(config, time, previous, co2)
  else
    Empty.new(config, time)
  end
end