Class: RubyHue::Bridge

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_hue/bridge.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ip_address, username = nil) ⇒ Bridge

Returns a new instance of Bridge.



14
15
16
17
# File 'lib/ruby_hue/bridge.rb', line 14

def initialize(ip_address, username=nil)
  @ip_address = ip_address
  @username = username
end

Instance Attribute Details

#ip_addressObject (readonly)

Returns the value of attribute ip_address.



3
4
5
# File 'lib/ruby_hue/bridge.rb', line 3

def ip_address
  @ip_address
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/ruby_hue/bridge.rb', line 4

def username
  @username
end

Class Method Details

.allObject



7
8
9
10
11
# File 'lib/ruby_hue/bridge.rb', line 7

def all
  Client.get_and_parse("http://www.meethue.com/api/nupnp").map do |bridge|
    self.new(bridge["internalipaddress"])
  end
end

Instance Method Details

#lightsObject



23
24
25
# File 'lib/ruby_hue/bridge.rb', line 23

def lights
  @lights ||= LightsCollection.new(self)
end

#resource_url_for(name) ⇒ Object



19
20
21
# File 'lib/ruby_hue/bridge.rb', line 19

def resource_url_for(name)
  "http://#{ip_address}/api/#{username}/#{name}"
end