Class: Soundcloud2000::Controllers::TrackController
- Inherits:
-
Controller
- Object
- Controller
- Soundcloud2000::Controllers::TrackController
- Defined in:
- lib/soundcloud2000/controllers/track_controller.rb
Instance Attribute Summary
Attributes inherited from Controller
Instance Method Summary collapse
- #bind_to(tracks) ⇒ Object
- #current_track ⇒ Object
- #fetch_user_with_message(message_to_display) ⇒ Object
-
#initialize(view, client) ⇒ TrackController
constructor
A new instance of TrackController.
- #load ⇒ Object
- #next_track ⇒ Object
Methods inherited from Controller
Constructor Details
#initialize(view, client) ⇒ TrackController
Returns a new instance of TrackController.
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 |
# File 'lib/soundcloud2000/controllers/track_controller.rb', line 12 def initialize(view, client) super(view) @client = client events.on(:key) do |key| case key when :enter @view.select events.trigger(:select, current_track) when :up, :k @view.up when :down, :j @view.down @tracks.load_more if @view.bottom? when :u @tracks.user = ('Change to SoundCloud user: ') @tracks.collection_to_load = :user @tracks.clear_and_replace when :f if @tracks.user.nil? @tracks.user = ('Change to favorites from SoundCloud user: ') end @tracks.collection_to_load = :favorites @tracks.clear_and_replace when :s @view.clear if @tracks.user.nil? @tracks.user = ('Change to SoundCloud user: ') end set = UI::Input.getstr('Change to SoundCloud playlist: ') @tracks.playlist = Models::Playlist.new(@client.resolve(@tracks.user.permalink + '/sets/' + set)) @tracks.collection_to_load = :playlist @tracks.clear_and_replace end end end |
Instance Method Details
#bind_to(tracks) ⇒ Object
64 65 66 67 |
# File 'lib/soundcloud2000/controllers/track_controller.rb', line 64 def bind_to(tracks) @tracks = tracks @view.bind_to(tracks) end |
#current_track ⇒ Object
60 61 62 |
# File 'lib/soundcloud2000/controllers/track_controller.rb', line 60 def current_track @tracks[@view.current] end |
#fetch_user_with_message(message_to_display) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/soundcloud2000/controllers/track_controller.rb', line 50 def () permalink = UI::Input.getstr() user_hash = @client.resolve(permalink) if user_hash Models::User.new(user_hash) else nil end end |
#load ⇒ Object
69 70 71 |
# File 'lib/soundcloud2000/controllers/track_controller.rb', line 69 def load @tracks.load end |
#next_track ⇒ Object
73 74 75 76 77 |
# File 'lib/soundcloud2000/controllers/track_controller.rb', line 73 def next_track @view.down @view.select events.trigger(:select, current_track) end |