class Soundcloud9000::Application
Public Class Methods
get_help()
click to toggle source
# File lib/soundcloud9000/application.rb, line 103 def self.get_help %( #{get_version} Usage: soundcloud9000 soundcloud9000 -h | --help soundcloud9000 -v | --version Options: -h --help show this message, then exit -v --version show soundcloud9000 version, then exit ) end
get_version()
click to toggle source
# File lib/soundcloud9000/application.rb, line 99 def self.get_version "soundcloud9000, version #{Gem.latest_spec_for('soundcloud9000').version}" end
logger()
click to toggle source
# File lib/soundcloud9000/application.rb, line 95 def self.logger @logger ||= Logger.new('debug.log') end
new(client)
click to toggle source
# File lib/soundcloud9000/application.rb, line 22 def initialize(client) $stderr.reopen('debug.log', 'w') @canvas = UI::Canvas.new @splash_controller = Controller.new( Splash.new( UI::Rect.new(0, 0, Curses.cols, Curses.lines) ) ) @track_controller = TrackController.new( TracksTable.new( UI::Rect.new(0, 5, Curses.cols, Curses.lines - 5) ), client ) @track_controller.bind_to(TrackCollection.new(client)) @player_controller = PlayerController.new( PlayerView.new( UI::Rect.new(0, 0, Curses.cols, 5) ), client ) @track_controller.events.on(:select) do |track| @player_controller.play(track) end @player_controller.events.on(:complete) do @track_controller.next_track end end
Public Instance Methods
handle(key)
click to toggle source
TODO: look at active controller and send key to active controller instead
# File lib/soundcloud9000/application.rb, line 78 def handle(key) case key when :left, :right, :space, :one, :two, :three, :four, :five, :six, :seven, :eight, :nine @player_controller.events.trigger(:key, key) when :down, :up, :enter, :u, :f, :s, :j, :k, :m, :h, :o @track_controller.events.trigger(:key, key) end end
main()
click to toggle source
# File lib/soundcloud9000/application.rb, line 55 def main loop do if @workaround_was_called_once_already handle UI::Input.get(-1) else @workaround_was_called_once_already = true handle UI::Input.get(0) @track_controller.load @track_controller.render end break if stop? end ensure @canvas.close end
run()
click to toggle source
# File lib/soundcloud9000/application.rb, line 72 def run @splash_controller.render main end
stop()
click to toggle source
# File lib/soundcloud9000/application.rb, line 87 def stop @stop = true end
stop?()
click to toggle source
# File lib/soundcloud9000/application.rb, line 91 def stop? @stop == true end