Class: Tictactoe::Sequence

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

Defined Under Namespace

Classes: Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ Sequence

Returns a new instance of Sequence.



14
15
16
17
18
19
20
21
22
# File 'lib/tictactoe/sequence.rb', line 14

def initialize(values)
  nodes = values.map{|value| Node.new(value)}
  nodes.each_with_index do |node, index|
    next_index = (index +1) % nodes.length
    node.next = nodes[next_index]
  end

  @first = nodes.first
end

Instance Attribute Details

#firstObject (readonly)

Returns the value of attribute first.



12
13
14
# File 'lib/tictactoe/sequence.rb', line 12

def first
  @first
end