Class: Pebble::Watch::MediaControlEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/pebble/watch/media_control_event.rb

Constant Summary collapse

BUTTONS =
{
  1 => :playpause,
  4 => :next,
  5 => :previous
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#buttonObject

Returns the value of attribute button.



4
5
6
# File 'lib/pebble/watch/media_control_event.rb', line 4

def button
  @button
end

Class Method Details

.parse(message) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pebble/watch/media_control_event.rb', line 12

def self.parse(message)
  button_id = message.unpack("C").first

  return nil unless BUTTONS.has_key?(button_id)

  event = new

  event.button = BUTTONS[button_id]

  event
end

Instance Method Details

#inspectObject



24
25
26
# File 'lib/pebble/watch/media_control_event.rb', line 24

def inspect
  self.button.to_s.capitalize
end