Class: MusicBox::Catalog::ReleaseArtist
- Inherits:
-
Object
- Object
- MusicBox::Catalog::ReleaseArtist
- Defined in:
- lib/musicbox/catalog/release_artist.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#anv ⇒ Object
Returns the value of attribute anv.
-
#artist ⇒ Object
linked on load.
-
#id ⇒ Object
Returns the value of attribute id.
-
#join ⇒ Object
Returns the value of attribute join.
-
#name ⇒ Object
Returns the value of attribute name.
-
#resource_url ⇒ Object
Returns the value of attribute resource_url.
-
#role ⇒ Object
Returns the value of attribute role.
-
#thumbnail_url ⇒ Object
Returns the value of attribute thumbnail_url.
-
#tracks ⇒ Object
Returns the value of attribute tracks.
Class Method Summary collapse
Instance Method Summary collapse
- #canonical_name ⇒ Object
-
#initialize(params = {}) ⇒ ReleaseArtist
constructor
A new instance of ReleaseArtist.
- #key ⇒ Object
- #to_s ⇒ Object
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
#active ⇒ Object
Returns the value of attribute active.
7 8 9 |
# File 'lib/musicbox/catalog/release_artist.rb', line 7 def active @active end |
#anv ⇒ Object
Returns the value of attribute anv.
8 9 10 |
# File 'lib/musicbox/catalog/release_artist.rb', line 8 def anv @anv end |
#artist ⇒ Object
linked on load
16 17 18 |
# File 'lib/musicbox/catalog/release_artist.rb', line 16 def artist @artist end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/musicbox/catalog/release_artist.rb', line 9 def id @id end |
#join ⇒ Object
Returns the value of attribute join.
10 11 12 |
# File 'lib/musicbox/catalog/release_artist.rb', line 10 def join @join end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/musicbox/catalog/release_artist.rb', line 11 def name @name end |
#resource_url ⇒ Object
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 |
#role ⇒ Object
Returns the value of attribute role.
13 14 15 |
# File 'lib/musicbox/catalog/release_artist.rb', line 13 def role @role end |
#thumbnail_url ⇒ Object
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 |
#tracks ⇒ Object
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_name ⇒ Object
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 |
#key ⇒ Object
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_s ⇒ Object
28 29 30 |
# File 'lib/musicbox/catalog/release_artist.rb', line 28 def to_s @name end |