Class: Snake::PreviousVectorRecord

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vector, remaining) ⇒ PreviousVectorRecord

Returns a new instance of PreviousVectorRecord.



7
8
9
10
# File 'lib/snake.rb', line 7

def initialize(vector, remaining)
  @vector = vector
  @remaining = remaining
end

Instance Attribute Details

#remainingObject (readonly)

Returns the value of attribute remaining.



6
7
8
# File 'lib/snake.rb', line 6

def remaining
  @remaining
end

#vectorObject (readonly)

Returns the value of attribute vector.



6
7
8
# File 'lib/snake.rb', line 6

def vector
  @vector
end

Instance Method Details

#decrementObject



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

def decrement
  @remaining -= 1
end

#incrementObject



16
17
18
# File 'lib/snake.rb', line 16

def increment
  @remaining += 1
end

#valid?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/snake.rb', line 20

def valid?
  @remaining > 0
end