Class: Grade
- Inherits:
-
Object
- Object
- Grade
- Defined in:
- lib/grade_calculator.rb
Instance Attribute Summary collapse
-
#grade ⇒ Object
readonly
Returns the value of attribute grade.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
-
#initialize(id, score) ⇒ Grade
constructor
A new instance of Grade.
- #to_s ⇒ Object
Constructor Details
#initialize(id, score) ⇒ Grade
Returns a new instance of Grade.
37 38 39 40 41 42 43 44 |
# File 'lib/grade_calculator.rb', line 37 def initialize(id, score) if isInvalidScore?(score) raise InvalidScoreExceptin.new(score) end @id = id @score = score @grade = calculateGrade(score) end |
Instance Attribute Details
#grade ⇒ Object (readonly)
Returns the value of attribute grade.
35 36 37 |
# File 'lib/grade_calculator.rb', line 35 def grade @grade end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
35 36 37 |
# File 'lib/grade_calculator.rb', line 35 def id @id end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
35 36 37 |
# File 'lib/grade_calculator.rb', line 35 def score @score end |
Instance Method Details
#to_s ⇒ Object
46 47 48 |
# File 'lib/grade_calculator.rb', line 46 def to_s "#{@id} => #{@grade}: #{@score}" end |