Class: BWA::Messages::SetTemperatureScale
- Inherits:
-
BWA::Message
- Object
- BWA::Message
- BWA::Messages::SetTemperatureScale
- Defined in:
- lib/bwa/messages/set_temperature_scale.rb
Constant Summary collapse
- MESSAGE_TYPE =
"\xbf\x27".b
- MESSAGE_LENGTH =
2
Instance Attribute Summary collapse
-
#scale ⇒ Object
Returns the value of attribute scale.
Attributes inherited from BWA::Message
Instance Method Summary collapse
-
#initialize(scale = nil) ⇒ SetTemperatureScale
constructor
A new instance of SetTemperatureScale.
- #inspect ⇒ Object
- #parse(data) ⇒ Object
- #serialize ⇒ Object
Methods inherited from BWA::Message
format_duration, format_time, inherited, #log?, parse
Constructor Details
#initialize(scale = nil) ⇒ SetTemperatureScale
Returns a new instance of SetTemperatureScale.
11 12 13 14 |
# File 'lib/bwa/messages/set_temperature_scale.rb', line 11 def initialize(scale = nil) super() self.scale = scale end |
Instance Attribute Details
#scale ⇒ Object
Returns the value of attribute scale.
9 10 11 |
# File 'lib/bwa/messages/set_temperature_scale.rb', line 9 def scale @scale end |
Instance Method Details
#inspect ⇒ Object
26 27 28 |
# File 'lib/bwa/messages/set_temperature_scale.rb', line 26 def inspect "#<BWA::Messages::SetTemperatureScale °#{scale.to_s[0].upcase}>" end |
#parse(data) ⇒ Object
16 17 18 |
# File 'lib/bwa/messages/set_temperature_scale.rb', line 16 def parse(data) self.scale = data[1].ord.zero? ? :fahrenheit : :celsius end |
#serialize ⇒ Object
20 21 22 23 24 |
# File 'lib/bwa/messages/set_temperature_scale.rb', line 20 def serialize data = +"\x01\x00" data[1] = ((scale == :fahrenheit) ? 0x00 : 0x01).chr super(data) end |