Class: MusicBrainz::Model::ScoredCollection::Entry
- Inherits:
-
Object
- Object
- MusicBrainz::Model::ScoredCollection::Entry
- Includes:
- Comparable
- Defined in:
- lib/rbrainz/model/scored_collection.rb
Overview
An entry in a ScoredCollection wrapping an entity and a corresponding search result score.
Instance Attribute Summary collapse
-
#entity ⇒ Object
Returns the value of attribute entity.
-
#score ⇒ Object
Returns the value of attribute score.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(entity, score = nil) ⇒ Entry
constructor
A new instance of Entry.
Constructor Details
#initialize(entity, score = nil) ⇒ Entry
38 39 40 41 |
# File 'lib/rbrainz/model/scored_collection.rb', line 38 def initialize(entity, score=nil) @entity = entity @score = score end |
Instance Attribute Details
#entity ⇒ Object
Returns the value of attribute entity.
36 37 38 |
# File 'lib/rbrainz/model/scored_collection.rb', line 36 def entity @entity end |
#score ⇒ Object
Returns the value of attribute score.
36 37 38 |
# File 'lib/rbrainz/model/scored_collection.rb', line 36 def score @score end |
Instance Method Details
#<=>(other) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/rbrainz/model/scored_collection.rb', line 43 def <=>(other) if self.score.nil? && other.score.nil? return self.entity <=> other.entity end return -1 if self.score.nil? return 1 if other.score.nil? return self.score <=> other.score end |