Class: Hue::VoiceParser

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/alexa_hue/hue/voice_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#fix_schedule_syntax, #numbers_to_times, #parse_time, #set_time

Constructor Details

#initialize(options = {}) ⇒ VoiceParser

Returns a new instance of VoiceParser.



10
11
12
# File 'lib/alexa_hue/hue/voice_parser.rb', line 10

def initialize(options={})
  @client = options[:js] ? Hue::JsClient.new(options[:js]) : Hue::Client.new
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



8
9
10
# File 'lib/alexa_hue/hue/voice_parser.rb', line 8

def client
  @client
end

Instance Method Details

#voice(string) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/alexa_hue/hue/voice_parser.rb', line 14

def voice(string)
  @client.reset
  @client.command << string

  parse_voice(string)

  if @client.command.include?("schedule")
    state = string.match(/off|on/)[0].to_sym rescue nil
    @client.schedule(*[string, state])
  else
    string.include?(' off') ? @client.off : @client.on
  end
end