Class: Hue::Config::Application
- Defined in:
- lib/hue/config/application.rb
Constant Summary collapse
- STRING_BRIDGE_ID =
'bridge_id'
- STRING_DEFAULT =
'default'
- STRING_ID =
'id'
Instance Attribute Summary collapse
-
#bridge_id ⇒ Object
readonly
Returns the value of attribute bridge_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Abstract
Class Method Summary collapse
Instance Method Summary collapse
- #==(rhs) ⇒ Object
-
#initialize(bridge_id, id, name = STRING_DEFAULT, path = self.class.file_path) ⇒ Application
constructor
A new instance of Application.
Methods inherited from Abstract
Constructor Details
#initialize(bridge_id, id, name = STRING_DEFAULT, path = self.class.file_path) ⇒ Application
Returns a new instance of Application.
30 31 32 33 34 |
# File 'lib/hue/config/application.rb', line 30 def initialize(bridge_id, id, name = STRING_DEFAULT, path = self.class.file_path) super(name, path) @bridge_id = bridge_id @id = id end |
Instance Attribute Details
#bridge_id ⇒ Object (readonly)
Returns the value of attribute bridge_id.
28 29 30 |
# File 'lib/hue/config/application.rb', line 28 def bridge_id @bridge_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28 29 30 |
# File 'lib/hue/config/application.rb', line 28 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/hue/config/application.rb', line 28 def name @name end |
Class Method Details
.default ⇒ Object
13 14 15 |
# File 'lib/hue/config/application.rb', line 13 def self.default named(STRING_DEFAULT) end |
.file_path ⇒ Object
9 10 11 |
# File 'lib/hue/config/application.rb', line 9 def self.file_path File.join(ENV['HOME'], ".#{Hue.device_type}", 'applications.yml') end |
.named(name) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/hue/config/application.rb', line 17 def self.named(name) yaml = read_file(file_path) if yaml && named_yaml = yaml[name] new(named_yaml[STRING_BRIDGE_ID], named_yaml[STRING_ID], name) else raise NotFound.new("Config named '#{name}' not found.") end end |
Instance Method Details
#==(rhs) ⇒ Object
36 37 38 39 40 |
# File 'lib/hue/config/application.rb', line 36 def ==(rhs) super(rhs) && self.bridge_id == rhs.bridge_id && self.id == rhs.id end |