Class: StayAwake::Buzzer
- Inherits:
-
Object
- Object
- StayAwake::Buzzer
- Includes:
- Singleton
- Defined in:
- lib/stay_awake/buzzer.rb
Instance Method Summary collapse
- #buzz ⇒ Object
- #buzzing? ⇒ Boolean
-
#initialize ⇒ Buzzer
constructor
A new instance of Buzzer.
- #shut_off ⇒ Object
Constructor Details
#initialize ⇒ Buzzer
Returns a new instance of Buzzer.
5 6 7 8 |
# File 'lib/stay_awake/buzzer.rb', line 5 def initialize @buzzing = false @strategy = nil end |
Instance Method Details
#buzz ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/stay_awake/buzzer.rb', line 14 def buzz unless buzzing? if StayAwake.config.url url = StayAwake.config.url elsif StayAwake.config.app_name url = "http://#{StayAwake.config.app_name}.herokuapp.com/" else raise ConfigurationError.new('config.url or config.app_name needed.') end start_buzzing(url) @buzzing = true end end |
#buzzing? ⇒ Boolean
10 11 12 |
# File 'lib/stay_awake/buzzer.rb', line 10 def buzzing? @buzzing end |
#shut_off ⇒ Object
29 30 31 32 |
# File 'lib/stay_awake/buzzer.rb', line 29 def shut_off @strategy.shut_off if buzzing? @buzzing = false end |