Class: Datastore
- Inherits:
-
Object
- Object
- Datastore
- Defined in:
- lib/lights/datastore.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#lights ⇒ Object
readonly
Returns the value of attribute lights.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#scenes ⇒ Object
readonly
Returns the value of attribute scenes.
-
#schedules ⇒ Object
readonly
Returns the value of attribute schedules.
-
#sensors ⇒ Object
readonly
Returns the value of attribute sensors.
Instance Method Summary collapse
- #all ⇒ Object
- #data ⇒ Object
-
#initialize(data = {}) ⇒ Datastore
constructor
A new instance of Datastore.
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Datastore
Returns a new instance of Datastore.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lights/datastore.rb', line 13 def initialize(data = {}) @data = {} @lights = BulbList.new(data["lights"]) @groups = GroupList.new(data["groups"]) @config = HueConfig.new(data["config"]) @schedules = ScheduleList.new(data["schedules"]) @scenes = SceneList.new(data["scenes"]) @rules = RuleList.new(data["rules"]) @sensors = SensorList.new(data["sensors"]) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/lights/datastore.rb', line 11 def config @config end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
11 12 13 |
# File 'lib/lights/datastore.rb', line 11 def groups @groups end |
#lights ⇒ Object (readonly)
Returns the value of attribute lights.
11 12 13 |
# File 'lib/lights/datastore.rb', line 11 def lights @lights end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
11 12 13 |
# File 'lib/lights/datastore.rb', line 11 def rules @rules end |
#scenes ⇒ Object (readonly)
Returns the value of attribute scenes.
11 12 13 |
# File 'lib/lights/datastore.rb', line 11 def scenes @scenes end |
#schedules ⇒ Object (readonly)
Returns the value of attribute schedules.
11 12 13 |
# File 'lib/lights/datastore.rb', line 11 def schedules @schedules end |
#sensors ⇒ Object (readonly)
Returns the value of attribute sensors.
11 12 13 |
# File 'lib/lights/datastore.rb', line 11 def sensors @sensors end |
Instance Method Details
#all ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/lights/datastore.rb', line 24 def all @lights.bulbs + \ @groups.groups + \ [@config] + \ @schedules.schedules + \ @scenes.scenes + \ @rules.rules + \ @sensors.sensors end |
#data ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/lights/datastore.rb', line 34 def data data = @data data["lights"] = @lights.data if !@lights.data.empty? data["groups"] = @groups.data if !@groups.data.empty? data["config"] = @config.data if !@config.data.empty? data["schedules"] = @schedules.data if !@schedules.data.empty? data["scenes"] = @scenes.data if !@scenes.data.empty? data["rules"] = @rules.data if !@rules.data.empty? data["sensors"] = @sensors.data if !@sensors.data.empty? data end |
#to_json(options = {}) ⇒ Object
46 47 48 |
# File 'lib/lights/datastore.rb', line 46 def to_json(={}) data.to_json end |