Class: LastfmM3u::Lastfm

Inherits:
Base
  • Object
show all
Defined in:
lib/lastfm-m3u/lastfm.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#m3u, #m3u_path

Instance Method Summary collapse

Constructor Details

#initialize(artist, options = OpenStruct.new) ⇒ Lastfm

Returns a new instance of Lastfm.



8
9
10
11
12
13
14
15
16
# File 'lib/lastfm-m3u/lastfm.rb', line 8

def initialize(artist, options=OpenStruct.new)
  init_config
  set_artist(artist)
  set_top_tracks
  @root_dir = options.directory
  @limit = options.limit
  @search_type = options.type || :file
  super()
end

Instance Attribute Details

#artistObject

Returns the value of attribute artist.



6
7
8
# File 'lib/lastfm-m3u/lastfm.rb', line 6

def artist
  @artist
end

#limitObject

Returns the value of attribute limit.



6
7
8
# File 'lib/lastfm-m3u/lastfm.rb', line 6

def limit
  @limit
end

#root_dirObject

Returns the value of attribute root_dir.



6
7
8
# File 'lib/lastfm-m3u/lastfm.rb', line 6

def root_dir
  @root_dir
end

#tracksObject

Returns the value of attribute tracks.



6
7
8
# File 'lib/lastfm-m3u/lastfm.rb', line 6

def tracks
  @tracks
end

Instance Method Details

#find_tracks(search_type = @search_type, progressbar = false) ⇒ Object



26
27
28
29
# File 'lib/lastfm-m3u/lastfm.rb', line 26

def find_tracks(search_type=@search_type, progressbar=false)
  check_for_invalid_search_type(search_type)
  found_tracks(tracks, search_type, progressbar)
end

#set_artist(artist) ⇒ Object



18
19
20
# File 'lib/lastfm-m3u/lastfm.rb', line 18

def set_artist(artist)
  @artist = Rockstar::Artist.new(artist)
end

#set_top_tracksObject



22
23
24
# File 'lib/lastfm-m3u/lastfm.rb', line 22

def set_top_tracks
  @tracks = @artist.top_tracks
end