Class: Co2Notify::Notifier
- Inherits:
-
Object
- Object
- Co2Notify::Notifier
- Defined in:
- lib/co2-notify/notifier.rb
Constant Summary collapse
- NORMALIZATION_CONSTANT =
10000.0.freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config) ⇒ Notifier
constructor
A new instance of Notifier.
- #start ⇒ Object
Constructor Details
#initialize(config) ⇒ Notifier
Returns a new instance of Notifier.
11 12 13 14 15 |
# File 'lib/co2-notify/notifier.rb', line 11 def initialize(config) @config = config @client = Co2Notify::HipchatClient.new(config) @status = Co2Notify::Status::Empty.new(config, Time.now) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/co2-notify/notifier.rb', line 6 def client @client end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/co2-notify/notifier.rb', line 6 def config @config end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/co2-notify/notifier.rb', line 6 def status @status end |
Class Method Details
.start ⇒ Object
2 3 4 |
# File 'lib/co2-notify/notifier.rb', line 2 def self.start new(Co2Notify::Config.get).start end |
Instance Method Details
#start ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/co2-notify/notifier.rb', line 17 def start loop do time = Time.now if time > start_time && time < stop_time notify end sleep timeout * 60 end rescue Interrupt end |