Class: Event

Inherits:
Object
  • Object
show all
Defined in:
lib/rlirc/event.rb

Overview

$Id: event.rb,v 1.6 2004/09/16 20:05:45 inando Exp $
$Source: /var/cvs/rlirc/rlirc/lib/rlirc/event.rb,v $

++

process lirc events

Instance Method Summary collapse

Constructor Details

#initialize(event_string) ⇒ Event



10
11
12
13
14
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
# File 'lib/rlirc/event.rb', line 10

def initialize(event_string)
    a = event_string.split
    raise "unkown event (#{event_string})" unless a.length == 4
    @code = a[0]
    @count = a[1].to_i
    @button = a[2]
    @remote = a[3]
  
    $mode.remote = @remote
    $global.remote = @remote
    $mode.code = @code
    $global.code = @code

    b = @button.downcase
    b.gsub!('+', 'up')
    b.gsub!('-', 'down')
    method = 'button_' + b
    if @count > 0 
        method += '_repeat'
    end
       
    puts "trying to run method #{method}" if $debug
    
    if @count == 0 
        $mode.send(method) if $mode.methods.include?(method)
        $global.send(method) if $global.methods.include?(method)
        if ('0'..'9').include?(@button)
            $mode.send('number', @button) if 
                $mode.methods.include?('number')
            $global.send('number', @button) if 
                $global.methods.include?('number')
        end
    else
        $mode.send(method, @count) if $mode.methods.include?(method)
        $global.send(method, @count) if $global.methods.include?(method)
    end

end