Class: PairMaker
- Inherits:
-
Object
- Object
- PairMaker
- Defined in:
- lib/work_together/pair_maker.rb
Instance Attribute Summary collapse
-
#batches ⇒ Object
Returns the value of attribute batches.
Instance Method Summary collapse
-
#initialize ⇒ PairMaker
constructor
A new instance of PairMaker.
- #make_groups(num_of_groups, students) ⇒ Object
- #make_pairs_mindful(students) ⇒ Object
- #make_pairs_progress(students) ⇒ Object
- #make_pairs_random(students) ⇒ Object
- #make_tables_mindful(students) ⇒ Object
- #make_tables_progress(students) ⇒ Object
- #make_tables_random(students) ⇒ Object
Constructor Details
#initialize ⇒ PairMaker
Returns a new instance of PairMaker.
7 8 9 |
# File 'lib/work_together/pair_maker.rb', line 7 def initialize @batches = [] end |
Instance Attribute Details
#batches ⇒ Object
Returns the value of attribute batches.
5 6 7 |
# File 'lib/work_together/pair_maker.rb', line 5 def batches @batches end |
Instance Method Details
#make_groups(num_of_groups, students) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/work_together/pair_maker.rb', line 51 def make_groups(num_of_groups, students) num_of_groups = students.length/num_of_groups.to_i students.shuffle.each_slice(num_of_groups).each do |slice| if slice.length == 1 Table.all.last.students << slice.first else Table.new(slice) end end end |
#make_pairs_mindful(students) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/work_together/pair_maker.rb', line 17 def make_pairs_mindful(students) sorted = sort_by_progress(students) two_from_batch(sorted) two_groups_of_two = [] self.batches.each_slice(2) {|slice| two_groups_of_two << slice} mindful_batch_of_two(two_groups_of_two) end |
#make_pairs_progress(students) ⇒ Object
25 26 27 28 29 |
# File 'lib/work_together/pair_maker.rb', line 25 def make_pairs_progress(students) sorted_students = sort_by_progress(students) two_from_batch(sorted_students) make_tables end |
#make_pairs_random(students) ⇒ Object
11 12 13 14 15 |
# File 'lib/work_together/pair_maker.rb', line 11 def make_pairs_random(students) students.shuffle! two_from_batch(students) make_tables end |
#make_tables_mindful(students) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/work_together/pair_maker.rb', line 43 def make_tables_mindful(students) sorted_students = sort_by_progress(students) four_from_batch(sorted_students) two_groups_of_four = [] self.batches.each_slice(2) {|slice| two_groups_of_four << slice} mindful_batch_of_four(two_groups_of_four) end |
#make_tables_progress(students) ⇒ Object
31 32 33 34 35 |
# File 'lib/work_together/pair_maker.rb', line 31 def make_tables_progress(students) sorted_students = sort_by_progress(students) four_from_batch(sorted_students) make_tables end |
#make_tables_random(students) ⇒ Object
37 38 39 40 41 |
# File 'lib/work_together/pair_maker.rb', line 37 def make_tables_random(students) students.shuffle! four_from_batch(students) make_tables end |