Class: MusicBrainz::Model::Entity
- Inherits:
-
Object
- Object
- MusicBrainz::Model::Entity
- Defined in:
- lib/rbrainz/model/entity.rb
Overview
A first-level MusicBrainz class.
All entities in MusicBrainz have unique IDs (which are MBID’s representing absolute URIs) and may have any number of #relations to other entities. This class is abstract and should not be instantiated.
Relations are differentiated by their target type, that means, where they link to. MusicBrainz currently supports four target types (artists, releases, tracks, and URLs) each identified using a URI. To get all relations with a specific target type, you can use #relations and pass one of the following constants as the parameter:
-
Relation::TO_ARTIST
-
Relation::TO_RELEASE
-
Relation::TO_TRACK
-
Relation::TO_URL
- See
-
Relation
Direct Known Subclasses
Constant Summary collapse
- ENTITY_TYPE =
The entity type of this entity. Must be set by child classes correctly.
Use #entity_type to query the type.
nil
Instance Attribute Summary collapse
-
#id ⇒ Object
The MusicBrainz ID.
Class Method Summary collapse
-
.entity_type ⇒ Object
Returns the entity type of the entity class.
Instance Method Summary collapse
-
#entity_type ⇒ Object
Returns the entity type of the instance.
-
#initialize(mbid = nil) ⇒ Entity
constructor
Create a new Entity.
Constructor Details
#initialize(mbid = nil) ⇒ Entity
Create a new Entity. You can assign a MusicBrainz identifier to the created entity with the parameter mbid (see id=).
47 48 49 |
# File 'lib/rbrainz/model/entity.rb', line 47 def initialize(mbid=nil) self.id = mbid end |
Instance Attribute Details
#id ⇒ Object
The MusicBrainz ID. A MBID containing an absolute URI.
43 44 45 |
# File 'lib/rbrainz/model/entity.rb', line 43 def id @id end |
Class Method Details
.entity_type ⇒ Object
Returns the entity type of the entity class.
Depending on the class this is :artist, :release, :track or :label.
74 75 76 |
# File 'lib/rbrainz/model/entity.rb', line 74 def self.entity_type self::ENTITY_TYPE end |
Instance Method Details
#entity_type ⇒ Object
Returns the entity type of the instance.
Depending on the class this is :artist, :release, :track or :label.
82 83 84 |
# File 'lib/rbrainz/model/entity.rb', line 82 def entity_type self.class.entity_type end |