Class: Vnehm::TracksViewCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/vnehm/tracks_view_command.rb

Direct Known Subclasses

ListCommand, SearchCommand

Constant Summary collapse

DEFAULT_LIMIT =
10
DEFAULT_OFFSET =
0

Instance Attribute Summary

Attributes inherited from Command

#options, #options_descs

Instance Method Summary collapse

Methods inherited from Command

#add_option, #arguments, #handle_options, #invoke, #program_name, #summary, #usage

Constructor Details

#initializeTracksViewCommand

Returns a new instance of TracksViewCommand.



10
11
12
# File 'lib/vnehm/tracks_view_command.rb', line 10

def initialize
  super
end

Instance Method Details

#executeObject



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
# File 'lib/vnehm/tracks_view_command.rb', line 14

def execute
  setup_environment

  old_offset = @offset

  @queue = []
  @track_manager = TrackManager.new(@options)

  tracks = get_tracks
  UI.term 'У Вас ещё нет аудиозаписей' if tracks.nil?

  loop do
    # If offset changed, update list of tracks
    unless old_offset == @offset
      tracks = get_tracks
      old_offset = @offset
    end

    if tracks.nil?
      prev_page
      next
    end

    show_menu(tracks)
  end
end