Class: StayAwake::Buzzer

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/stay_awake/buzzer.rb

Instance Method Summary collapse

Constructor Details

#initializeBuzzer

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

#buzzObject



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

Returns:

  • (Boolean)


10
11
12
# File 'lib/stay_awake/buzzer.rb', line 10

def buzzing?
  @buzzing
end

#shut_offObject



29
30
31
32
# File 'lib/stay_awake/buzzer.rb', line 29

def shut_off
  @strategy.shut_off if buzzing?
  @buzzing = false
end