class LearnParty::GroupMaker

Constants

VALID_ARGS

Attributes

options[RW]

Public Instance Methods

has_valid_keys?() click to toggle source
# File lib/learn_party.rb, line 27
def has_valid_keys?
  options.keys.all? {|key| VALID_ARGS[:valid_keys].include?(key)}
end
has_valid_values?() click to toggle source
# File lib/learn_party.rb, line 31
def has_valid_values?
  if options["sort_type"]
    if VALID_ARGS[:sort_type].include?(options["sort_type"])
      true
    else
      false
    end
  else
    true
  end
end
run(options) click to toggle source
# File lib/learn_party.rb, line 15
def run(options)
  @options = ActiveSupport::HashWithIndifferentAccess.new(options)
  validate_args
  students = Student.new(options[:collection]).generate_batch_students
  generator = Generator.new(students: students, groups_of: options[:groups_of], number_of_groups: options[:number_of_groups], sort_type: options[:sort_type])
  generator.make_groups
end
validate_args() click to toggle source
# File lib/learn_party.rb, line 23
def validate_args
  (has_valid_keys? && has_valid_values?) ? true : (raise GroupMakerArgError.new)
end