Class: Soundcloud9000::Application
- Inherits:
-
Object
- Object
- Soundcloud9000::Application
- Includes:
- Controllers, Models, Views
- Defined in:
- lib/soundcloud9000/application.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#handle(key) ⇒ Object
TODO: look at active controller and send key to active controller instead.
-
#initialize(client) ⇒ Application
constructor
A new instance of Application.
- #main ⇒ Object
- #run ⇒ Object
- #stop ⇒ Object
- #stop? ⇒ Boolean
Constructor Details
#initialize(client) ⇒ Application
Returns a new instance of Application.
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 51 52 53 |
# 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 |
Class Method Details
.get_help ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 |
# 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 ⇒ Object
99 100 101 |
# File 'lib/soundcloud9000/application.rb', line 99 def self.get_version "soundcloud9000, version #{Gem.latest_spec_for('soundcloud9000').version}" end |
.logger ⇒ Object
95 96 97 |
# File 'lib/soundcloud9000/application.rb', line 95 def self.logger @logger ||= Logger.new('debug.log') end |
Instance Method Details
#handle(key) ⇒ Object
TODO: look at active controller and send key to active controller instead
78 79 80 81 82 83 84 85 |
# 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 ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# 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 ⇒ Object
72 73 74 75 |
# File 'lib/soundcloud9000/application.rb', line 72 def run @splash_controller.render main end |
#stop ⇒ Object
87 88 89 |
# File 'lib/soundcloud9000/application.rb', line 87 def stop @stop = true end |
#stop? ⇒ Boolean
91 92 93 |
# File 'lib/soundcloud9000/application.rb', line 91 def stop? @stop == true end |