Class: WorkTogether

Inherits:
Object
  • Object
show all
Defined in:
lib/work_together.rb,
lib/work_together/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path_to_csv = nil) ⇒ WorkTogether

Returns a new instance of WorkTogether.



11
12
13
14
# File 'lib/work_together.rb', line 11

def initialize(path_to_csv=nil)
  @roster = path_to_csv
  @pair_maker = PairMaker.new
end

Instance Attribute Details

#pair_makerObject

Returns the value of attribute pair_maker.



9
10
11
# File 'lib/work_together.rb', line 9

def pair_maker
  @pair_maker
end

#rosterObject

Returns the value of attribute roster.



9
10
11
# File 'lib/work_together.rb', line 9

def roster
  @roster
end

#studentsObject

Returns the value of attribute students.



9
10
11
# File 'lib/work_together.rb', line 9

def students
  @students
end

Instance Method Details

#display_tablesObject



32
33
34
35
36
37
38
39
40
# File 'lib/work_together.rb', line 32

def display_tables
  Table.all.each_with_index do |table, i|
      puts "Group #{i + 1}:"
      table.students.each do |student|
        puts student.name
      end
      puts "-------------------"
    end
end

#generate_togetherness(options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/work_together.rb', line 16

def generate_togetherness(options)
  make_students
  flag = options[1][2..-1]
  if options.include?("pairs")
    pair_maker.public_send("make_pairs_#{flag}", self.students)
    display_tables
  elsif options.include?("tables")
    pair_maker.public_send("make_tables_#{flag}", self.students)
    display_tables
  elsif options.include?("--help")
    help
  else
    puts "Please enter a valid command. Type work-together --help for more."
  end
end

#helpObject



42
43
44
45
46
47
48
49
50
# File 'lib/work_together.rb', line 42

def help
  puts "Available commands:"
    puts "work-together pairs --random path/to/csv-roster         generate pairs randomly"
    puts "work-together pairs --progress path/to/csv-roster       generate pairs grouped by similar progress"
    puts "work-together pairs --mindful path/to/csv-roster        generate pairs with one person who is more advanced, one person less advanced"
    puts "work-together tables --random path/to/csv-roster        generate tables randomly"
    puts "work-together tables --random path/to/csv-roster        generate tables grouped by similar progress"
    puts "work-together tables --random path/to/csv-roster        generate tables with some people more advanced, some less"
end

#make_studentsObject



52
53
54
55
# File 'lib/work_together.rb', line 52

def make_students
  Parser.parse_and_make_students(roster)
  @students = Student.all
end