Class: Roku::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/roku/input.rb

Instance Method Summary collapse

Instance Method Details

#runObject



5
6
7
8
9
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
# File 'lib/roku/input.rb', line 5

def run
  while (input = read_char)
    case input
    when ' '
      Roku::Client.keypress(:Play)
    when "\r"
      Roku::Client.keypress(:Select)
    when "\e[A"
      Roku::Client.keypress(:Up)
    when "\e[B"
      Roku::Client.keypress(:Down)
    when "\e[C"
      Roku::Client.keypress(:Right)
    when "\e[D"
      Roku::Client.keypress(:Left)
    when "\u007F"
      Roku::Client.keypress(:Back)
    when "\e[1;5A"
      Roku::Client.keypress(:VolumeUp)
    when "\e[1;5B"
      Roku::Client.keypress(:VolumeDown)
    when 'a'
      query = prompt('Launch: ')
      app = Roku::Client.apps.find { |a| a.name.casecmp(query) }
      if app.nil?
        print "\rNo app found."
      else
        print "\rLaunching #{app.name}."
        app.launch!
      end
    when 'q', "\u0003"
      break
    else
      puts input.inspect
    end
  end
end