Class: MusicBox::Catalog::ReleaseArtist

Inherits:
Object
  • Object
show all
Defined in:
lib/musicbox/catalog/release_artist.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ ReleaseArtist

Returns a new instance of ReleaseArtist.



24
25
26
# File 'lib/musicbox/catalog/release_artist.rb', line 24

def initialize(params={})
  params.each { |k, v| send("#{k}=", v) }
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



7
8
9
# File 'lib/musicbox/catalog/release_artist.rb', line 7

def active
  @active
end

#anvObject

Returns the value of attribute anv.



8
9
10
# File 'lib/musicbox/catalog/release_artist.rb', line 8

def anv
  @anv
end

#artistObject

linked on load



16
17
18
# File 'lib/musicbox/catalog/release_artist.rb', line 16

def artist
  @artist
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/musicbox/catalog/release_artist.rb', line 9

def id
  @id
end

#joinObject

Returns the value of attribute join.



10
11
12
# File 'lib/musicbox/catalog/release_artist.rb', line 10

def join
  @join
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/musicbox/catalog/release_artist.rb', line 11

def name
  @name
end

#resource_urlObject

Returns the value of attribute resource_url.



12
13
14
# File 'lib/musicbox/catalog/release_artist.rb', line 12

def resource_url
  @resource_url
end

#roleObject

Returns the value of attribute role.



13
14
15
# File 'lib/musicbox/catalog/release_artist.rb', line 13

def role
  @role
end

#thumbnail_urlObject

Returns the value of attribute thumbnail_url.



14
15
16
# File 'lib/musicbox/catalog/release_artist.rb', line 14

def thumbnail_url
  @thumbnail_url
end

#tracksObject

Returns the value of attribute tracks.



15
16
17
# File 'lib/musicbox/catalog/release_artist.rb', line 15

def tracks
  @tracks
end

Class Method Details

.artists_to_s(artists) ⇒ Object



18
19
20
21
22
# File 'lib/musicbox/catalog/release_artist.rb', line 18

def self.artists_to_s(artists)
  artists.map do |artist|
    artist.name + ((artist.join == ',') ? artist.join : (' ' + artist.join))
  end.flatten.join(' ').squeeze(' ').strip
end

Instance Method Details

#canonical_nameObject



32
33
34
35
36
37
38
39
40
# File 'lib/musicbox/catalog/release_artist.rb', line 32

def canonical_name
  name = (@@canonical_names[@name] || @name).sub(/\s\(\d+\)/, '')  # handle 'Nico (3)'
  if @@personal_names.include?(name)
    elems = name.split(/\s+/)
    [elems[-1], elems[0..-2].join(' ')].join(', ')
  else
    name
  end
end

#keyObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/musicbox/catalog/release_artist.rb', line 42

def key
  key = ''
  tokens = canonical_name.tokenize
  while (token = tokens.shift) && key.length < 4
    if key.empty?
      key << token[0..2].capitalize
    else
      key << token[0].upcase
    end
  end
  key
end

#to_sObject



28
29
30
# File 'lib/musicbox/catalog/release_artist.rb', line 28

def to_s
  @name
end