Class: AgentStatusBulb::Bulb

Inherits:
Object
  • Object
show all
Defined in:
lib/agent_status_bulb/bulb.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device) ⇒ Bulb

Returns a new instance of Bulb.



12
13
14
# File 'lib/agent_status_bulb/bulb.rb', line 12

def initialize(device)
  @device = device
end

Class Method Details

.from_config(config) ⇒ Object



7
8
9
10
# File 'lib/agent_status_bulb/bulb.rb', line 7

def self.from_config(config)
  client = Switchbot::Client.new(config.fetch(:token), config.fetch(:secret))
  new(client.color_bulb(config.fetch(:device_id)))
end

Instance Method Details

#blueObject



16
17
18
# File 'lib/agent_status_bulb/bulb.rb', line 16

def blue
  apply_color('0:0:255')
end

#greenObject



24
25
26
# File 'lib/agent_status_bulb/bulb.rb', line 24

def green
  apply_color('0:255:0')
end

#offObject



28
29
30
# File 'lib/agent_status_bulb/bulb.rb', line 28

def off
  @device.off
end

#orangeObject



20
21
22
# File 'lib/agent_status_bulb/bulb.rb', line 20

def orange
  apply_color('255:125:0')
end