Class: BWA::Messages::ToggleItem
- Inherits:
-
BWA::Message
- Object
- BWA::Message
- BWA::Messages::ToggleItem
- Defined in:
- lib/bwa/messages/toggle_item.rb
Constant Summary collapse
- MESSAGE_TYPE =
"\x0a\xbf\x11".force_encoding(Encoding::ASCII_8BIT)
- MESSAGE_LENGTH =
2
Instance Attribute Summary collapse
-
#item ⇒ Object
Returns the value of attribute item.
Attributes inherited from BWA::Message
Instance Method Summary collapse
-
#initialize(item = nil) ⇒ ToggleItem
constructor
A new instance of ToggleItem.
- #inspect ⇒ Object
- #parse(data) ⇒ Object
- #serialize ⇒ Object
Methods inherited from BWA::Message
format_duration, format_time, inherited, parse
Constructor Details
#initialize(item = nil) ⇒ ToggleItem
Returns a new instance of ToggleItem.
9 10 11 |
# File 'lib/bwa/messages/toggle_item.rb', line 9 def initialize(item = nil) self.item = item end |
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
7 8 9 |
# File 'lib/bwa/messages/toggle_item.rb', line 7 def item @item end |
Instance Method Details
#inspect ⇒ Object
35 36 37 |
# File 'lib/bwa/messages/toggle_item.rb', line 35 def inspect "#<BWA::Messages::ToggleItem #{item}>" end |
#parse(data) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/bwa/messages/toggle_item.rb', line 13 def parse(data) self.item = case data[0].ord when 0x04; :pump1 when 0x05; :pump2 when 0x11; :light1 when 0x50; :temperature_range when 0x51; :heating_mode end end |
#serialize ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bwa/messages/toggle_item.rb', line 23 def serialize data = "\x00\x00" data[0] = (case setting when :pump1; 0x04 when :pump2; 0x05 when :light1; 0x11 when :temperature_range; 0x50 when :heating_mode; 0x51 end).chr super(data) end |