Class: InchCI::GradeListCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/inch_ci/grade_list_collection.rb

Constant Summary collapse

GRADES =
%w(A B C U)

Instance Method Summary collapse

Constructor Details

#initialize(code_objects) ⇒ GradeListCollection


7
8
9
10
11
# File 'lib/inch_ci/grade_list_collection.rb', line 7

def initialize(code_objects)
  @count = code_objects.count
  @grade_lists = create_grade_lists(code_objects)
  @grade_percentages = calculate_grade_percentages(@grade_lists)
end

Instance Method Details

#[](grade) ⇒ Object


13
14
15
# File 'lib/inch_ci/grade_list_collection.rb', line 13

def [](grade)
  @grade_lists[grade]
end

#each(&block) ⇒ Object


17
18
19
20
21
# File 'lib/inch_ci/grade_list_collection.rb', line 17

def each(&block)
  GRADES.each do |grade|
    block.call(@grade_lists[grade])
  end
end

#percent(grade) ⇒ Object


23
24
25
# File 'lib/inch_ci/grade_list_collection.rb', line 23

def percent(grade)
  @grade_percentages[grade.to_s]
end