Class: Mostscrobbled::Artist

Inherits:
Object
  • Object
show all
Defined in:
lib/mostscrobbled/artist.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}, *args) ⇒ Artist

Returns a new instance of Artist.



6
7
8
9
10
11
# File 'lib/mostscrobbled/artist.rb', line 6

def initialize(attrs = {}, *args) 
  super(*args)
  attrs.each do |k,v|
    self.send "#{k}=", v
  end
end

Instance Attribute Details

#image_extralargeObject

Returns the value of attribute image_extralarge.



4
5
6
# File 'lib/mostscrobbled/artist.rb', line 4

def image_extralarge
  @image_extralarge
end

#image_largeObject

Returns the value of attribute image_large.



4
5
6
# File 'lib/mostscrobbled/artist.rb', line 4

def image_large
  @image_large
end

#image_mediumObject

Returns the value of attribute image_medium.



4
5
6
# File 'lib/mostscrobbled/artist.rb', line 4

def image_medium
  @image_medium
end

#image_megaObject

Returns the value of attribute image_mega.



4
5
6
# File 'lib/mostscrobbled/artist.rb', line 4

def image_mega
  @image_mega
end

#image_smallObject

Returns the value of attribute image_small.



4
5
6
# File 'lib/mostscrobbled/artist.rb', line 4

def image_small
  @image_small
end

#mbidObject

Returns the value of attribute mbid.



4
5
6
# File 'lib/mostscrobbled/artist.rb', line 4

def mbid
  @mbid
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/mostscrobbled/artist.rb', line 4

def name
  @name
end

#playcountObject

Returns the value of attribute playcount.



4
5
6
# File 'lib/mostscrobbled/artist.rb', line 4

def playcount
  @playcount
end

#streamableObject

Returns the value of attribute streamable.



4
5
6
# File 'lib/mostscrobbled/artist.rb', line 4

def streamable
  @streamable
end

#tagcountObject

Returns the value of attribute tagcount.



4
5
6
# File 'lib/mostscrobbled/artist.rb', line 4

def tagcount
  @tagcount
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/mostscrobbled/artist.rb', line 4

def url
  @url
end

Class Method Details

.build_artist(node) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/mostscrobbled/artist.rb', line 13

def self.build_artist(node)
	(artist = Artist.new).tap do
		[:name, :playcount, :tagcount, :mbid, :url, :streamable].each do |attribute|
			artist.send("#{attribute}=", node.xpath(".//#{attribute}").first.content)
		end
		node.xpath(".//image").each do |image_node| # set :image_small, :image_medium, :image_large, :image_extralarge, :image_mega
			artist.send("image_#{image_node.attributes["size"].value}=", image_node.children.first.content) if image_node.children.first
		end
	end
end