class Spoonerize::Bumper
Class that handles bumping an index.
Attributes
The maximum before index wraps back to zero.
@return [Integer]
The number after being bumped.
@return [Integer]
Public Class Methods
Sets the bumper relative to the current index of words array. The value is automatically bumped once when instantiated. If on the last element of the words array, sets the bumper to 0.
@param [Integer] initial_value
@param [Integer] max_value
@param [Boolean] reverse Flip the order
# File lib/spoonerize/bumper.rb, line 28 def initialize(initial_value, max_value, reverse = false) @max_value = max_value @reverse = reverse @value = bump_value(initial_value) end
Public Instance Methods
Increments/Decrements the bumper. If on the last element of the words array, sets the bumper to 0. We don't need to worry about resetting the value to 0 when going in reverse, because when the array index is negative, it reads from the end of the array, which is already what we want.
@return [Integer]
# File lib/spoonerize/bumper.rb, line 42 def bump @value = bump_value(value) end
Should we decrement instead of increment?
@return [Boolean]
# File lib/spoonerize/bumper.rb, line 50 def reverse? @reverse end