Class: Spotify::Music::Importer::CollectionRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/spotify/music/importer/collection_record.rb

Instance Method Summary collapse

Constructor Details

#initialize(row, options = {}) ⇒ CollectionRecord

Returns a new instance of CollectionRecord.



7
8
9
10
11
# File 'lib/spotify/music/importer/collection_record.rb', line 7

def initialize(row, options = {})
  @row = row
  @clean_album = options.delete(:clean_album) { false }
  @clean_track = options.delete(:clean_track) { false }
end

Instance Method Details

#albumObject



29
30
31
32
33
34
35
# File 'lib/spotify/music/importer/collection_record.rb', line 29

def album
  if @clean_album
    AlbumNameCleaner.new(@row['Album']).clean
  else
    @row['Album']
  end
end

#artistObject



21
22
23
24
25
26
27
# File 'lib/spotify/music/importer/collection_record.rb', line 21

def artist
  if @clean_album
    @row['Artist'].gsub('(Special Edition)', '').strip
  else
    @row['Artist']
  end
end

#nameObject



13
14
15
16
17
18
19
# File 'lib/spotify/music/importer/collection_record.rb', line 13

def name
  if @clean_track
    TrackNameCleaner.new(@row['Name']).clean
  else
    @row['Name']
  end
end

#to_json(options = {}) ⇒ Object



41
42
43
# File 'lib/spotify/music/importer/collection_record.rb', line 41

def to_json(options = {})
  { :name => name, :album => album, :artist => artist }.to_json(options)
end

#to_sObject



37
38
39
# File 'lib/spotify/music/importer/collection_record.rb', line 37

def to_s
  "Name: #{name} Album: #{album} Artist: #{artist}"
end