Class: Ruku::TkClient

Inherits:
Object
  • Object
show all
Defined in:
lib/ruku/clients/tk.rb

Instance Method Summary collapse

Constructor Details

#initializeTkClient

Returns a new instance of TkClient.



4
5
6
7
8
9
10
# File 'lib/ruku/clients/tk.rb', line 4

def initialize
  sm = YAMLStorage.new
  sm.load
  @remote = Remote.new(sm.boxes.first.host, 8080)

  launch
end

Instance Method Details

#launchObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ruku/clients/tk.rb', line 12

def launch
  require 'tk'
  root = TkRoot.new() { title "Roku Remote"}
  root.bind('KeyPress-Left'){
    @remote.left
  }
  root.bind('KeyPress-Right'){
    @remote.right
  }
  root.bind('KeyPress-Up'){
    @remote.up
  }
  root.bind('KeyPress-Down'){
    @remote.down
  }
  root.bind('KeyPress-Return'){
    @remote.select
  }
  root.bind('KeyPress-space'){
    @remote.pause
  }
  Tk.mainloop
end