Module: Core

Included in:
Quiyo
Defined in:
lib/quiyo/core.rb

Instance Method Summary collapse

Instance Method Details

#helpObject



52
53
54
# File 'lib/quiyo/core.rb', line 52

def help
  p "Some help text here"
end

#readline_histObject



8
9
10
11
12
13
14
15
# File 'lib/quiyo/core.rb', line 8

def readline_hist
  line = Readline.readline(prompt, true)
  return nil if line.nil?
  if line =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == line
    Readline::HISTORY.pop
  end
  line
end

#showpromptObject



2
3
4
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
42
43
44
45
46
47
48
49
50
# File 'lib/quiyo/core.rb', line 2

def showprompt
  Readline.completion_append_character = " "
  Readline.completion_proc = Proc.new { |str|
    Dir[PATH+str+'*'].grep( /^#{Regexp.escape(str)}/ )
  }

  def readline_hist
    line = Readline.readline(prompt, true)
    return nil if line.nil?
    if line =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == line
      Readline::HISTORY.pop
    end
    line
  end

  while line = readline_hist
    @mpd.connect unless @mpd.connected?
    action = line.split
    case action[0]
      when "np", "now-playing";           nowplaying
      when "info", "stats";               info

      when "pl", "play";                  play(action[1])
      when "pa", "pause";                 pause
      when "st", "stop";                  stop
      when "nx", "next";                  playnext
      when "prev", "previous";            playprevious

      when "lspl", "lsplaylist";          lsplist
      when "clear", "clearplaylist";      clearplist
      when "add", "addtoplaylist";        addtoplist(action)

      when "search";                      search(action)
      when "lsartists", "list-artists";   list("artists")
      when "lsalbums", "list-albums";     list("albums", action)

      when "love";                        love
      when "loved", "loves";              loved

      when "vol", "volume";               vol(action[1])

      when "quit", "exit";                quit

      when "v", "verbose";                eval(action.drop(1).join(" "))

      else;                               help
    end
  end
end