Class: BWA::Messages::SetTime
- Inherits:
-
BWA::Message
- Object
- BWA::Message
- BWA::Messages::SetTime
- Defined in:
- lib/bwa/messages/set_time.rb
Constant Summary collapse
- MESSAGE_TYPE =
"\xbf\x21".b
- MESSAGE_LENGTH =
2
Instance Attribute Summary collapse
-
#hour ⇒ Object
Returns the value of attribute hour.
-
#minute ⇒ Object
Returns the value of attribute minute.
-
#twenty_four_hour_time ⇒ Object
Returns the value of attribute twenty_four_hour_time.
Attributes inherited from BWA::Message
Instance Method Summary collapse
-
#initialize(hour = nil, minute = nil, twenty_four_hour_time = nil) ⇒ SetTime
constructor
A new instance of SetTime.
- #inspect ⇒ Object
- #parse(data) ⇒ Object
- #serialize ⇒ Object
Methods inherited from BWA::Message
format_duration, format_time, inherited, #log?, parse
Constructor Details
#initialize(hour = nil, minute = nil, twenty_four_hour_time = nil) ⇒ SetTime
Returns a new instance of SetTime.
11 12 13 14 |
# File 'lib/bwa/messages/set_time.rb', line 11 def initialize(hour = nil, minute = nil, twenty_four_hour_time = nil) super() self.hour, self.minute, self.twenty_four_hour_time = hour, minute, twenty_four_hour_time end |
Instance Attribute Details
#hour ⇒ Object
Returns the value of attribute hour.
9 10 11 |
# File 'lib/bwa/messages/set_time.rb', line 9 def hour @hour end |
#minute ⇒ Object
Returns the value of attribute minute.
9 10 11 |
# File 'lib/bwa/messages/set_time.rb', line 9 def minute @minute end |
#twenty_four_hour_time ⇒ Object
Returns the value of attribute twenty_four_hour_time.
9 10 11 |
# File 'lib/bwa/messages/set_time.rb', line 9 def twenty_four_hour_time @twenty_four_hour_time end |
Instance Method Details
#inspect ⇒ Object
28 29 30 |
# File 'lib/bwa/messages/set_time.rb', line 28 def inspect "#<BWA::Messages::SetTime #{Status.format_time(hour, minute, twenty_four_hour_time: twenty_four_hour_time)}>" end |
#parse(data) ⇒ Object
16 17 18 19 20 |
# File 'lib/bwa/messages/set_time.rb', line 16 def parse(data) self.hour = data[0].ord & 0x7f self.minute = data[1].ord self.twenty_four_hour_time = !!(data[0].ord & 0x80) end |
#serialize ⇒ Object
22 23 24 25 26 |
# File 'lib/bwa/messages/set_time.rb', line 22 def serialize hour_encoded = hour hour_encoded |= 0x80 if twenty_four_hour_time super("#{hour_encoded.chr}#{minute.chr}") end |