Class: LIRC::Messages::ButtonPress

Inherits:
Struct
  • Object
show all
Defined in:
lib/lirc/messages.rb

Overview

code is the hex code sent by the remote button is the name of the button (if found in lircd.conf) remote is the name of the remote (if found)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#buttonObject

Returns the value of attribute button

Returns:

  • (Object)

    the current value of button



27
28
29
# File 'lib/lirc/messages.rb', line 27

def button
  @button
end

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



27
28
29
# File 'lib/lirc/messages.rb', line 27

def code
  @code
end

#remoteObject

Returns the value of attribute remote

Returns:

  • (Object)

    the current value of remote



27
28
29
# File 'lib/lirc/messages.rb', line 27

def remote
  @remote
end

#repeat_countObject

Returns the value of attribute repeat_count

Returns:

  • (Object)

    the current value of repeat_count



27
28
29
# File 'lib/lirc/messages.rb', line 27

def repeat_count
  @repeat_count
end

Class Method Details

.parse(line) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/lirc/messages.rb', line 28

def self.parse(line)
  bits = line.split(" ")
  if bits[0] =~ /[^0-9a-fA-F]/ || bits[1] =~ /[^0-9]/
    raise ParseError, "invalid button press message '#{line}'"
  end

  # convert hex chars to an integer
  bits[0] = bits[0].to_i(16)
  bits[1] = bits[1].to_i
  new(*bits)
end