Sha256: 0abac6afdeae9a58e8ef8e015b4303709c75e52d50860d49293743288e2ffde9

Contents?: true

Size: 712 Bytes

Versions: 1

Compression:

Stored size: 712 Bytes

Contents

# -*- encoding: utf-8 -*-
module MusicBrainz
  class Track < MusicBrainz::Base
    attr_accessor :position, :recording_id, :title, :length

    def self.find mbid
      xml = Nokogiri::XML(self.load(:recording, :id => mbid))
      self.parse_xml(xml) unless xml.nil?
    end

    def self.parse_xml xml
      @track = MusicBrainz::Track.new
      @track.position = self.safe_get_value(xml, 'position').to_i
      @track.recording_id = self.safe_get_attr(xml, 'recording', 'id')
      @track.title = self.safe_get_value(xml, 'recording > title')
      @track.length = self.safe_get_value(xml, 'length').to_i
      @track.length = self.safe_get_value(xml, 'recording > length').to_i
      @track
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
musicbrainz-0.6.0 lib/musicbrainz/track.rb