class Tradfri::Gateway

Constants

DISCOVERY_PATH
SCHEME

Public Instance Methods

bulbs() click to toggle source
# File lib/tradfri/gateway.rb, line 17
def bulbs
  devices.select(&:bulb?)
end
devices() click to toggle source
# File lib/tradfri/gateway.rb, line 9
def devices
  client.get(key, discovery_uri).split(',').
    map { |link| %r{\A</(?<uri>[^>]+)>}.match(link) }.
    compact.
    map { |match| discovery_uri.merge(match[:uri]) }.
    map { |uri| Device.new(self, uri) }
end
get(uri) click to toggle source
# File lib/tradfri/gateway.rb, line 21
def get(uri)
  client.get key, uri
end
put(uri, payload) click to toggle source
# File lib/tradfri/gateway.rb, line 25
def put(uri, payload)
  client.put key, uri, payload
end

Private Instance Methods

discovery_uri() click to toggle source
# File lib/tradfri/gateway.rb, line 29
        def discovery_uri
  URI::Generic.build \
    scheme: SCHEME,
    host: host,
    port: port,
    path: DISCOVERY_PATH
end