Class: SCRABBLR::Score

Inherits:
Object
  • Object
show all
Defined in:
lib/score.rb

Overview

simple container for scrabble scores

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(word, score, explanation) ⇒ Score

Returns a new instance of Score.



9
10
11
12
13
# File 'lib/score.rb', line 9

def initialize(word, score, explanation)
  @word = word
  @score = score
  @explanation = explanation
end

Instance Attribute Details

#explanationObject

Returns the value of attribute explanation.



7
8
9
# File 'lib/score.rb', line 7

def explanation
  @explanation
end

#scoreObject

Returns the value of attribute score.



7
8
9
# File 'lib/score.rb', line 7

def score
  @score
end

#wordObject

Returns the value of attribute word.



7
8
9
# File 'lib/score.rb', line 7

def word
  @word
end

Instance Method Details

#<=>(other) ⇒ Object



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

def <=> other
  other.score <=> @score
end

#inspectObject



15
16
17
# File 'lib/score.rb', line 15

def inspect
   "Scrabble score [word=#{@word}, score=#{@score}]"
end