Class: Nehm::TrackManager
- Inherits:
-
Object
- Object
- Nehm::TrackManager
- Defined in:
- lib/nehm/track_manager.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ TrackManager
constructor
A new instance of TrackManager.
- #likes(limit, offset) ⇒ Object
- #posts(limit, offset) ⇒ Object
- #process_tracks(tracks) ⇒ Object
- #search(query, limit, offset) ⇒ Object
- #track_from_url(url) ⇒ Object
Constructor Details
#initialize(options) ⇒ TrackManager
Returns a new instance of TrackManager.
9 10 11 |
# File 'lib/nehm/track_manager.rb', line 9 def initialize() setup_environment() end |
Instance Method Details
#likes(limit, offset) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/nehm/track_manager.rb', line 24 def likes(limit, offset) UI.term "Invalid limit value\nIt should be more than 0" if limit <= 0 UI.term "Invalid offset value\nIt should be more or equal 0" if offset < 0 likes = Client.tracks(limit, offset, :likes, @uid) return nil if likes.empty? filter(likes) convert(likes) end |
#posts(limit, offset) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nehm/track_manager.rb', line 35 def posts(limit, offset) UI.term "Invalid limit value\nIt should be more than 0" if limit <= 0 UI.term "Invalid offset value\nIt should be more or equal 0" if offset < 0 posts = Client.tracks(limit, offset, :posts, @uid) return nil if posts.empty? posts.map! { |hash| hash['track'] } filter(posts) convert(posts) end |
#process_tracks(tracks) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/nehm/track_manager.rb', line 13 def process_tracks(tracks) tracks.reverse_each do |track| dl(track) tag(track) track.artwork.suicide @playlist.add_track(track) if @playlist UI.newline end UI.success 'Done!' end |
#search(query, limit, offset) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/nehm/track_manager.rb', line 57 def search(query, limit, offset) UI.term "Invalid limit value\nIt should be more than 0" if limit <= 0 UI.term "Invalid offset value\nIt should be more or equal 0" if offset < 0 found = Client.search(query, limit, offset) return nil if found.empty? filter(found) convert(found) end |