Class: BracketGraph::LoserGraph

Inherits:
Graph
  • Object
show all
Defined in:
lib/bracket_graph/loser_graph.rb

Defined Under Namespace

Classes: IdGenerator

Instance Attribute Summary

Attributes inherited from Graph

#root, #seats, #starting_seats

Instance Method Summary collapse

Methods inherited from Graph

#[], #as_json, #seed

Constructor Details

#initialize(root_or_size) ⇒ LoserGraph

Returns a new instance of LoserGraph.

Raises:

  • (ArgumentError)


17
18
19
20
# File 'lib/bracket_graph/loser_graph.rb', line 17

def initialize root_or_size
  raise ArgumentError, 'a loser graph require at least 4 participants' if root_or_size.is_a?(Fixnum) && root_or_size < 4
  super
end

Instance Method Details

#sizeObject



22
23
24
# File 'lib/bracket_graph/loser_graph.rb', line 22

def size
  starting_seats.count + 1
end