Method: BracketGraph::Graph#seed

Defined in:
lib/bracket_graph/graph.rb

#seed(teams, shuffle: false) ⇒ Object

Fills the starting seats with the given ‘teams`

Parameters:

  • teams (Array)

    Teams to place as payload in the starting seats

  • shuffle (true, false) (defaults to: false)

    Indicates if teams shoud be shuffled

Raises:

  • (ArgumentError)

    if ‘teams.count` is greater then `#size`



37
38
39
40
41
42
43
# File 'lib/bracket_graph/graph.rb', line 37

def seed teams, shuffle: false
  raise ArgumentError, "Only a maximum of #{size} teams is allowed" if teams.size > size
  slots = TeamSeeder.new(teams, size, shuffle: shuffle).slots
  starting_seats.sort_by(&:position).each do |seat|
    seat.payload = slots.shift
  end
end