Class: Ban::DoorEvent
Constant Summary collapse
- CMD =
0x37
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(state) ⇒ DoorEvent
constructor
A new instance of DoorEvent.
- #name ⇒ Object
- #open? ⇒ Boolean
- #to_hash ⇒ Object
- #to_s ⇒ Object
Methods inherited from Event
Constructor Details
#initialize(state) ⇒ DoorEvent
Returns a new instance of DoorEvent.
11 12 13 |
# File 'lib/ban/events/door_event.rb', line 11 def initialize(state) @state = state end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
5 6 7 |
# File 'lib/ban/events/door_event.rb', line 5 def state @state end |
Class Method Details
.parse(data) ⇒ Object
7 8 9 |
# File 'lib/ban/events/door_event.rb', line 7 def self.parse(data) new(Ban.decode7bit(data).downcase) end |
Instance Method Details
#name ⇒ Object
15 16 17 |
# File 'lib/ban/events/door_event.rb', line 15 def name open? ? 'door-opened' : 'door-closed' end |
#open? ⇒ Boolean
23 24 25 |
# File 'lib/ban/events/door_event.rb', line 23 def open? @state == 'open' end |
#to_hash ⇒ Object
19 20 21 |
# File 'lib/ban/events/door_event.rb', line 19 def to_hash { 'state' => @state } end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/ban/events/door_event.rb', line 27 def to_s "door: #{open? ? 'opened' : 'closed'}" end |