Class: BrainzReleases::Release
- Inherits:
-
Object
- Object
- BrainzReleases::Release
- Defined in:
- lib/brainz_releases/release.rb
Instance Attribute Summary collapse
-
#artist_mbid ⇒ Object
Returns the value of attribute artist_mbid.
-
#artist_name ⇒ Object
Returns the value of attribute artist_name.
-
#country ⇒ Object
Returns the value of attribute country.
-
#date_available ⇒ Object
Returns the value of attribute date_available.
-
#format ⇒ Object
Returns the value of attribute format.
-
#label ⇒ Object
Returns the value of attribute label.
-
#mbid ⇒ Object
Returns the value of attribute mbid.
-
#release_type ⇒ Object
Returns the value of attribute release_type.
-
#title ⇒ Object
Returns the value of attribute title.
-
#track_count ⇒ Object
Returns the value of attribute track_count.
Class Method Summary collapse
Instance Method Summary collapse
-
#attributes ⇒ Object
Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
-
#initialize(*args, &block) ⇒ Release
constructor
A new instance of Release.
Constructor Details
#initialize(*args, &block) ⇒ Release
Returns a new instance of Release.
6 7 8 |
# File 'lib/brainz_releases/release.rb', line 6 def initialize(*args, &block) self.instance_eval(&block) if block end |
Instance Attribute Details
#artist_mbid ⇒ Object
Returns the value of attribute artist_mbid.
4 5 6 |
# File 'lib/brainz_releases/release.rb', line 4 def artist_mbid @artist_mbid end |
#artist_name ⇒ Object
Returns the value of attribute artist_name.
4 5 6 |
# File 'lib/brainz_releases/release.rb', line 4 def artist_name @artist_name end |
#country ⇒ Object
Returns the value of attribute country.
4 5 6 |
# File 'lib/brainz_releases/release.rb', line 4 def country @country end |
#date_available ⇒ Object
Returns the value of attribute date_available.
4 5 6 |
# File 'lib/brainz_releases/release.rb', line 4 def date_available @date_available end |
#format ⇒ Object
Returns the value of attribute format.
4 5 6 |
# File 'lib/brainz_releases/release.rb', line 4 def format @format end |
#label ⇒ Object
Returns the value of attribute label.
4 5 6 |
# File 'lib/brainz_releases/release.rb', line 4 def label @label end |
#mbid ⇒ Object
Returns the value of attribute mbid.
4 5 6 |
# File 'lib/brainz_releases/release.rb', line 4 def mbid @mbid end |
#release_type ⇒ Object
Returns the value of attribute release_type.
4 5 6 |
# File 'lib/brainz_releases/release.rb', line 4 def release_type @release_type end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/brainz_releases/release.rb', line 4 def title @title end |
#track_count ⇒ Object
Returns the value of attribute track_count.
4 5 6 |
# File 'lib/brainz_releases/release.rb', line 4 def track_count @track_count end |
Class Method Details
.build_from_node(node) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/brainz_releases/release.rb', line 10 def self.build_from_node(node) Release.new do |release| release.mbid = node["id"] release.artist_name = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:artist-credit/xmlns:name-credit/xmlns:artist/xmlns:name").first.content rescue nil release.artist_mbid = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:artist-credit/xmlns:name-credit/xmlns:artist").first['id'] release.title = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:title").first.content rescue nil release.release_type = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:release-group").first['type'] release.date_available = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:date").first.content rescue nil release.track_count = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:medium-list/xmlns:track-count").first.content rescue nil release.format = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:medium-list/xmlns:medium/xmlns:format").first.content rescue nil release.label = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:label-info-list/xmlns:label-info/xmlns:label/xmlns:name").first.content rescue nil release.country = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:country").first.content rescue nil end end |
Instance Method Details
#attributes ⇒ Object
Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
26 27 28 |
# File 'lib/brainz_releases/release.rb', line 26 def attributes Hash[instance_variables.map { |name| [name[1..-1].to_sym, instance_variable_get(name)] }] end |