Class: LastfmPathFinder::Artist
- Inherits:
-
Object
- Object
- LastfmPathFinder::Artist
- Includes:
- Redis::Objects
- Defined in:
- lib/lastfm_path_finder/artist.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params) ⇒ Artist
constructor
A new instance of Artist.
- #related_artists ⇒ Object
- #related_artists_in_lastfm ⇒ Object
- #related_artists_without_lastfm ⇒ Object
Constructor Details
#initialize(params) ⇒ Artist
Returns a new instance of Artist.
11 12 13 14 15 |
# File 'lib/lastfm_path_finder/artist.rb', line 11 def initialize params params.symbolize_keys! self.id = params [:id] || (params[:name]).parameterize self.name = params[:name] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/lastfm_path_finder/artist.rb', line 6 def id @id end |
Class Method Details
.find_in_lastfm(name) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/lastfm_path_finder/artist.rb', line 33 def self.find_in_lastfm name begin LastfmPathFinder::Artist.new(LastfmPathFinder::Settings.lastfm_api.artist.get_info(name)) rescue Lastfm::ApiError => e nil end end |
Instance Method Details
#related_artists ⇒ Object
19 20 21 22 |
# File 'lib/lastfm_path_finder/artist.rb', line 19 def = .blank? ? : end |
#related_artists_in_lastfm ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/lastfm_path_finder/artist.rb', line 24 def artists = LastfmPathFinder::Settings.lastfm_api.artist.get_similar(self.name.value) .clear artists.each do |artist| [artist["name"]] = artist["match"].to_f end end |
#related_artists_without_lastfm ⇒ Object
17 |
# File 'lib/lastfm_path_finder/artist.rb', line 17 alias_method :related_artists_without_lastfm, :related_artists |