class LIFX::LAN::ProtocolPath
@private
Attributes
raw_site[RW]
raw_target[RW]
tagged[RW]
Public Class Methods
new(raw_site: "\x00".b * 6, raw_target: "\x00".b * 8, tagged: false, site_id: nil, device_id: nil, tag_ids: nil)
click to toggle source
# File lib/lifx/lan/protocol_path.rb, line 15 def initialize(raw_site: "\x00".b * 6, raw_target: "\x00".b * 8, tagged: false, site_id: nil, device_id: nil, tag_ids: nil) self.raw_site = raw_site self.raw_target = raw_target self.tagged = tagged self.site_id = site_id if site_id self.device_id = device_id if device_id self.tag_ids = tag_ids if tag_ids end
Public Instance Methods
all_sites?()
click to toggle source
# File lib/lifx/lan/protocol_path.rb, line 65 def all_sites? site_id == "000000000000" end
device_id()
click to toggle source
# File lib/lifx/lan/protocol_path.rb, line 34 def device_id if !tagged? raw_target[0...6].unpack('H*').join else nil end end
device_id=(value)
click to toggle source
# File lib/lifx/lan/protocol_path.rb, line 42 def device_id=(value) self.raw_target = [value].pack('H16').b self.tagged = false end
site_id()
click to toggle source
# File lib/lifx/lan/protocol_path.rb, line 26 def site_id raw_site.unpack('H*').join end
site_id=(value)
click to toggle source
# File lib/lifx/lan/protocol_path.rb, line 30 def site_id=(value) self.raw_site = [value].pack('H12').b end
tag_ids()
click to toggle source
# File lib/lifx/lan/protocol_path.rb, line 47 def tag_ids if tagged? tag_ids_from_field(tags_field) else nil end end
tag_ids=(values)
click to toggle source
# File lib/lifx/lan/protocol_path.rb, line 55 def tag_ids=(values) self.tags_field = values.reduce(0) do |value, tag_id| value |= 2 ** tag_id end end
tagged?()
click to toggle source
# File lib/lifx/lan/protocol_path.rb, line 61 def tagged? !!tagged end