Class: LastfmItunes::Playlist
- Inherits:
-
Object
- Object
- LastfmItunes::Playlist
- Defined in:
- lib/lastfm-itunes/playlist.rb
Instance Attribute Summary collapse
-
#itunes ⇒ Object
readonly
Returns the value of attribute itunes.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#search ⇒ Object
readonly
Returns the value of attribute search.
-
#tracks ⇒ Object
readonly
Returns the value of attribute tracks.
Instance Method Summary collapse
- #fetch_tracks(&block) ⇒ Object
-
#initialize(args) ⇒ Playlist
constructor
A new instance of Playlist.
- #track_paths ⇒ Object
Constructor Details
#initialize(args) ⇒ Playlist
Returns a new instance of Playlist.
6 7 8 9 10 11 12 13 14 |
# File 'lib/lastfm-itunes/playlist.rb', line 6 def initialize(args) @search = Lastfm::Search.new( credentials: args.fetch(:credentials), search_class: args.fetch(:search_class, LastfmItunes::Lastfm::Artist), name: args.fetch(:name, nil), limit: args.fetch(:limit, nil)) @itunes = Itunes.new args.fetch(:itunes_xml_path) @tracks = [] end |
Instance Attribute Details
#itunes ⇒ Object (readonly)
Returns the value of attribute itunes.
3 4 5 |
# File 'lib/lastfm-itunes/playlist.rb', line 3 def itunes @itunes end |
#limit ⇒ Object
Returns the value of attribute limit.
4 5 6 |
# File 'lib/lastfm-itunes/playlist.rb', line 4 def limit @limit end |
#search ⇒ Object (readonly)
Returns the value of attribute search.
3 4 5 |
# File 'lib/lastfm-itunes/playlist.rb', line 3 def search @search end |
#tracks ⇒ Object (readonly)
Returns the value of attribute tracks.
3 4 5 |
# File 'lib/lastfm-itunes/playlist.rb', line 3 def tracks @tracks end |
Instance Method Details
#fetch_tracks(&block) ⇒ Object
16 17 18 19 |
# File 'lib/lastfm-itunes/playlist.rb', line 16 def fetch_tracks(&block) @tracks = @search.my_top_tracks(@itunes.tracks, &block) end |
#track_paths ⇒ Object
21 22 23 |
# File 'lib/lastfm-itunes/playlist.rb', line 21 def track_paths @tracks.map { |t| t.location_path } end |