Class: LifxHttp::LifxLight
- Inherits:
-
Object
- Object
- LifxHttp::LifxLight
- Extended by:
- Forwardable
- Defined in:
- lib/lifx_http/lifx_light.rb
Instance Attribute Summary collapse
-
#light_id ⇒ Object
readonly
Returns the value of attribute light_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ LifxLight
constructor
A new instance of LifxLight.
- #inspect ⇒ Object
- #update_info ⇒ Object
Constructor Details
#initialize(data) ⇒ LifxLight
Returns a new instance of LifxLight.
19 20 21 22 23 24 |
# File 'lib/lifx_http/lifx_light.rb', line 19 def initialize(data) @light_id = data["id"] @data = OpenStruct.new(data) @updated_at = Time.now @http_api = Api.with_default_selector(selector) end |
Instance Attribute Details
#light_id ⇒ Object (readonly)
Returns the value of attribute light_id.
11 12 13 |
# File 'lib/lifx_http/lifx_light.rb', line 11 def light_id @light_id end |
Class Method Details
.get_lights ⇒ Object
13 14 15 16 17 |
# File 'lib/lifx_http/lifx_light.rb', line 13 def self.get_lights @lights ||= Api.with_default_selector("all").get_info.map do |data| LifxLight.new(data) end end |
Instance Method Details
#inspect ⇒ Object
31 32 33 |
# File 'lib/lifx_http/lifx_light.rb', line 31 def inspect "#<#{self.class.name} light_id=#{light_id.inspect} label=#{label.inspect} connected=#{connected.inspect} power=#{power.inspect} color=#{color.inspect} brightness=#{brightness.inspect} product_name=#{product_name.inspect} last_seen=#{last_seen.inspect} seconds_since_seen=#{seconds_since_seen.inspect} @updated_at=#{@updated_at}>" end |
#update_info ⇒ Object
26 27 28 29 |
# File 'lib/lifx_http/lifx_light.rb', line 26 def update_info @data ||= OpenStruct.new(@http_api.get_info) @updated_at = Time.now end |