Class: Pebble::Watch::AppMessageEvent
- Defined in:
- lib/pebble/watch/app_message_event.rb
Defined Under Namespace
Modules: TupleType
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Class Method Summary collapse
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
13 14 15 |
# File 'lib/pebble/watch/app_message_event.rb', line 13 def data @data end |
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
11 12 13 |
# File 'lib/pebble/watch/app_message_event.rb', line 11 def transaction_id @transaction_id end |
#uuid ⇒ Object
Returns the value of attribute uuid.
12 13 14 |
# File 'lib/pebble/watch/app_message_event.rb', line 12 def uuid @uuid end |
Class Method Details
.parse(raw_message) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pebble/watch/app_message_event.rb', line 15 def self.parse() return nil if .length < 19 , transaction_id, uuid, dictionary_length = [0, 19].unpack("CCA16C") data = {} offset = 19 dictionary_length.times do |i| key, tuple_type, item_length = [offset, 7].unpack("CL>S<") offset += 7 format = case tuple_type when TupleType::ByteArray; "a*" when TupleType::String; "A*" when TupleType::UnsignedInteger case item_length when 1; "C" when 2; "S<" when 4; "L<" end when TupleType::Integer case item_length when 1; "c" when 2; "s<" when 4; "l<" end end item_data = [offset, item_length].unpack(format).first offset += item_length data[key] = item_data end event = new event.transaction_id = transaction_id event.uuid = uuid event.data = data event end |