Class: Spotify::Music::Importer::SpotifyMatch
- Inherits:
-
Object
- Object
- Spotify::Music::Importer::SpotifyMatch
- Defined in:
- lib/spotify/music/importer/spotify_match.rb
Instance Method Summary collapse
- #album ⇒ Object
- #artist ⇒ Object
- #found_match? ⇒ Boolean
- #id ⇒ Object
-
#initialize(results, options = {}) ⇒ SpotifyMatch
constructor
A new instance of SpotifyMatch.
- #name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(results, options = {}) ⇒ SpotifyMatch
Returns a new instance of SpotifyMatch.
5 6 7 8 9 |
# File 'lib/spotify/music/importer/spotify_match.rb', line 5 def initialize(results, = {}) @results = results @clean_album = .delete(:clean_album) { false } @clean_track = .delete(:clean_track) { false } end |
Instance Method Details
#album ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/spotify/music/importer/spotify_match.rb', line 27 def album if @clean_album AlbumNameCleaner.new(@results["tracks"]['items'].first['album']['name']).clean else @results["tracks"]['items'].first['album']['name'] end end |
#artist ⇒ Object
23 24 25 |
# File 'lib/spotify/music/importer/spotify_match.rb', line 23 def artist @results["tracks"]['items'].first['artists'].first['name'] end |
#found_match? ⇒ Boolean
11 12 13 |
# File 'lib/spotify/music/importer/spotify_match.rb', line 11 def found_match? @results['tracks']['items'].count > 0 end |
#id ⇒ Object
35 36 37 |
# File 'lib/spotify/music/importer/spotify_match.rb', line 35 def id @results ["tracks"]["items"].first["id"] end |
#name ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/spotify/music/importer/spotify_match.rb', line 15 def name if @clean_track TrackNameCleaner.new(@results["tracks"]["items"].first["name"]).clean else @results["tracks"]["items"].first["name"] end end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/spotify/music/importer/spotify_match.rb', line 39 def to_s "Name: #{name} Album: #{album} Artist: #{artist} id: #{id}" end |