Class: Spandx::Core::Score

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/spandx/core/score.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#itemObject (readonly)

Returns the value of attribute item.



8
9
10
# File 'lib/spandx/core/score.rb', line 8

def item
  @item
end

#scoreObject (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

Returns:

  • (Boolean)


19
20
21
# File 'lib/spandx/core/score.rb', line 19

def empty?
  score.nil? || item.nil?
end

#to_sObject



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