Class: Ban::IrEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/ban/events/ir_event.rb

Constant Summary collapse

CMD =
0x36

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Event

#valid?

Constructor Details

#initialize(code) ⇒ IrEvent

Returns a new instance of IrEvent.



11
12
13
# File 'lib/ban/events/ir_event.rb', line 11

def initialize(code)
  @code = code
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/ban/events/ir_event.rb', line 5

def code
  @code
end

Class Method Details

.parse(data) ⇒ Object



7
8
9
# File 'lib/ban/events/ir_event.rb', line 7

def self.parse(data)
  new(Ban.decode7bit(data).to_i)
end

Instance Method Details

#hexObject



19
20
21
# File 'lib/ban/events/ir_event.rb', line 19

def hex
  code.to_s(16)
end

#nameObject



15
16
17
# File 'lib/ban/events/ir_event.rb', line 15

def name
  'ir-received'
end

#to_hashObject



23
24
25
# File 'lib/ban/events/ir_event.rb', line 23

def to_hash
  { 'code' => @code, 'hex' => hex }
end

#to_sObject



27
28
29
# File 'lib/ban/events/ir_event.rb', line 27

def to_s
  "#{code} (0x#{hex})"
end