Class: StudentGradeManager::Grade

Inherits:
Object
  • Object
show all
Defined in:
lib/student_grade_manager/grade.rb,
sig/student_grade_manager.rbs

Overview

Represents a grade with a subject, score, and coefficient.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject:, score:, coefficient:) ⇒ Grade

Returns a new instance of Grade.



8
9
10
11
12
13
14
15
16
# File 'lib/student_grade_manager/grade.rb', line 8

def initialize(subject:, score:, coefficient:)
  validate_subject(subject)
  validate_score(score)
  validate_coefficient(coefficient)

  @subject = subject.strip
  @score = score
  @coefficient = coefficient
end

Instance Attribute Details

#coefficientNumeric (readonly)

Returns the value of attribute coefficient.

Returns:

  • (Numeric)


6
7
8
# File 'lib/student_grade_manager/grade.rb', line 6

def coefficient
  @coefficient
end

#scoreNumeric (readonly)

Returns the value of attribute score.

Returns:

  • (Numeric)


6
7
8
# File 'lib/student_grade_manager/grade.rb', line 6

def score
  @score
end

#subjectString (readonly)

Returns the value of attribute subject.

Returns:

  • (String)


6
7
8
# File 'lib/student_grade_manager/grade.rb', line 6

def subject
  @subject
end