Class: Hue::Config::Bridge

Inherits:
Abstract show all
Defined in:
lib/hue/config/bridge.rb

Instance Attribute Summary collapse

Attributes inherited from Abstract

#name, #path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

#==, #delete

Constructor Details

#initialize(id, uri, path = self.class.file_path) ⇒ Bridge



23
24
25
26
# File 'lib/hue/config/bridge.rb', line 23

def initialize(id, uri, path = self.class.file_path)
  super(id, path)
  @uri = uri
end

Instance Attribute Details

#uriObject

Returns the value of attribute uri.



21
22
23
# File 'lib/hue/config/bridge.rb', line 21

def uri
  @uri
end

Class Method Details

.file_pathObject



5
6
7
# File 'lib/hue/config/bridge.rb', line 5

def self.file_path
  File.join(ENV['HOME'], ".#{Hue.device_type}", 'bridges.yml')
end

.find(id) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/hue/config/bridge.rb', line 9

def self.find(id)
  yaml = read_file(file_path)
  entry = yaml.select { |k,v| k.to_s == id.to_s }
  if entry.empty?
    nil
  else
    new(id, entry[id]['uri'])
  end
end

Instance Method Details

#idObject



28
29
30
# File 'lib/hue/config/bridge.rb', line 28

def id
  self.name
end

#write(overwrite_existing_key = true) ⇒ Object



32
33
34
# File 'lib/hue/config/bridge.rb', line 32

def write(overwrite_existing_key = true)
  super(overwrite_existing_key)
end