Class: Spandx::Core::Score
- Inherits:
-
Object
- Object
- Spandx::Core::Score
- Includes:
- Comparable
- Defined in:
- lib/spandx/core/score.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(score, item) ⇒ Score
constructor
A new instance of Score.
- #to_s ⇒ Object
- #update(score, item) ⇒ Object
Constructor Details
#initialize(score, item) ⇒ Score
Returns a new instance of Score.
10 11 12 |
# File 'lib/spandx/core/score.rb', line 10 def initialize(score, item) update(score || 0.0, item) end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
8 9 10 |
# File 'lib/spandx/core/score.rb', line 8 def item @item end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
8 9 10 |
# File 'lib/spandx/core/score.rb', line 8 def score @score end |
Instance Method Details
#<=>(other) ⇒ Object
23 24 25 |
# File 'lib/spandx/core/score.rb', line 23 def <=>(other) score <=> other.score end |
#empty? ⇒ Boolean
19 20 21 |
# File 'lib/spandx/core/score.rb', line 19 def empty? score.nil? || item.nil? end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/spandx/core/score.rb', line 27 def to_s "#{score}: #{item}" end |
#update(score, item) ⇒ Object
14 15 16 17 |
# File 'lib/spandx/core/score.rb', line 14 def update(score, item) @score = score @item = item end |