Class: Rankmatic::Submission
- Inherits:
-
Object
- Object
- Rankmatic::Submission
- Defined in:
- lib/rankmatic/submission.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#scores ⇒ Object
readonly
Returns the value of attribute scores.
Instance Method Summary collapse
- #average ⇒ Object
-
#initialize(id:, scores: []) ⇒ Submission
constructor
A new instance of Submission.
- #score_count ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(id:, scores: []) ⇒ Submission
Returns a new instance of Submission.
5 6 7 8 |
# File 'lib/rankmatic/submission.rb', line 5 def initialize(id:, scores: []) @id = id @scores = scores end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/rankmatic/submission.rb', line 3 def id @id end |
#scores ⇒ Object (readonly)
Returns the value of attribute scores.
3 4 5 |
# File 'lib/rankmatic/submission.rb', line 3 def scores @scores end |
Instance Method Details
#average ⇒ Object
14 15 16 |
# File 'lib/rankmatic/submission.rb', line 14 def average total / score_count end |
#score_count ⇒ Object
18 19 20 |
# File 'lib/rankmatic/submission.rb', line 18 def score_count scores.length end |
#total ⇒ Object
10 11 12 |
# File 'lib/rankmatic/submission.rb', line 10 def total scores.reduce(:+) end |