Class: Tictactoe::Sequence
- Inherits:
-
Object
- Object
- Tictactoe::Sequence
- Defined in:
- lib/tictactoe/sequence.rb
Defined Under Namespace
Classes: Node
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
Instance Method Summary collapse
-
#initialize(values) ⇒ Sequence
constructor
A new instance of Sequence.
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
#first ⇒ Object (readonly)
Returns the value of attribute first.
12 13 14 |
# File 'lib/tictactoe/sequence.rb', line 12 def first @first end |