Class | MusicBrainz::Model::MBID |
In: |
lib/rbrainz/model/mbid.rb
|
Parent: | Object |
Represents a MusicBrainz identifier.
A MusicBrainz identifier is an URI identifying a resource like an artist or a track. It consists of an URI prefix, the entity type it refers to and an UUID that identifies the referenced entity.
Example:
http://musicbrainz.org/artist/6a2ca1ac-408d-49b0-a7f6-cd608f2f684f
See: | musicbrainz.org/doc/MusicBrainzIdentifier |
UUID_REGEXP | = | Regexp.new('^' + PATTERN::UUID + '$') | A regular expression describing the format of a UUID. | |
ENTITY_TYPE_REGEXP | = | Regexp.new('^' + PATTERN::ENTITY_TYPE + '$') | A regular expression to test if a string is a valid entity type. | |
ENTITY_URI_REGEXP | = | Regexp.new('^' + PATTERN::ENTITY_URI + '$') | A regular expression describing a MusicBrainz identifier URI. | |
ENTITY_URI | = | 'http://musicbrainz.org/%s/%s' | The general format of a MusicBrainz identifier URI. |
entity | [R] | The entity type (:artist, :label, :release_group, :release, :track) this MBID references. |
uuid | [R] | The UUID of the referenced entity. |
str can be either a complete identifier or just the UUID part of it. In the latter case the entity type (:artist, :label, :release_group, :release or :track) has to be specified as well.
Examples:
require 'rbrainz' include MusicBrainz id = Model::MBID.new('http://musicbrainz.org/artist/10bf95b6-30e3-44f1-817f-45762cdc0de0') id = Model::MBID.new('10bf95b6-30e3-44f1-817f-45762cdc0de0', :artist)
Raises: | UnknownEntityError, EntityTypeNotMatchingError, InvalidMBIDError |
Tries to convert str into a MBID using its to_mbid method.
If str does not respond to to_mbid a new MBID is created using the given parameters.
See: | new |
See: | String#to_mbid, URI::HTTP#to_mbid |
Raises: | UnknownEntityError, EntityTypeNotMatchingError, InvalidMBIDError |
Compares this MBID with another one.
Two MBIDs are considered equal if both their entity type and their UUID are equal.
Returns self.
If entity_type is given it must match the entity type of the MBID or an EntityTypeNotMatchingError will be raised.
Raises: | EntityTypeNotMatchingError |