Class: WorkTogether::Generator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(batch_id = nil) ⇒ Generator

Returns a new instance of Generator.



15
16
17
18
# File 'lib/work_together.rb', line 15

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

Instance Attribute Details

#batch_idObject

Returns the value of attribute batch_id.



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

def batch_id
  @batch_id
end

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#keysObject

Returns the value of attribute keys.



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

def keys
  @keys
end

#pair_makerObject

Returns the value of attribute pair_maker.



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

def pair_maker
  @pair_maker
end

Instance Method Details

#generate_togetherness(options, quiet = nil) ⇒ Object



21
22
23
24
# File 'lib/work_together.rb', line 21

def generate_togetherness(options, quiet=nil)
  make_batch
  make_groups(options, quiet)
end

#make_batchObject



26
27
28
29
30
# File 'lib/work_together.rb', line 26

def make_batch
  configure_client
  student_data = get_and_parse_csv
  Student.generate_from_data(student_data)
end

#make_batch_dataObject



32
33
34
35
# File 'lib/work_together.rb', line 32

def make_batch_data
  configure_client
  get_and_parse_csv
end

#make_groups(options, quiet = nil, students = nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/work_together.rb', line 37

def make_groups(options, quiet=nil, students=nil)
  students ||= Student.all
  # binding.pry
  flag = options[1][2..-1]
  if options.include?("pairs")
    pair_maker.public_send("make_pairs_#{flag}", students)
  elsif options.include?("tables")
    pair_maker.public_send("make_tables_#{flag}", students)
  elsif options.include?("groups")
    pair_maker.public_send("make_groups", flag, students)
  elsif options.include?("--help")
    help
  else
    puts "Please enter a valid command. Type work-together --help for more."
  end
  if !quiet && Group.all.length > 0
    Group.display_groups 
  else
    Group.all
  end
end