Sha256: b1f64b4776fb42452aa46f3b0d5eb95bc26df7546060a34a340795f91dea009e

Contents?: true

Size: 604 Bytes

Versions: 3

Compression:

Stored size: 604 Bytes

Contents

module WordSearch
  module TwoDimensional
    class PositionWord < PositionWord::Base
      private

      def place_letter(letter)
        plane[coordinate.x][coordinate.y].letter = letter
      end

      def update_coordinates
        coordinate.x += direction.x
        coordinate.y += direction.y
      end

      def positive_last_coordinates?
        last_x >= 0 && last_y >= 0
      end

      def last_coordinates_in_plane?
        last_x < plane.x && last_y < plane.y
      end

      def letter_at(position)
        plane.dig(x_at(position), y_at(position)).letter
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
word_search-0.5.1 lib/word_search/two_dimensional/position_word.rb
word_search-0.5.0 lib/word_search/two_dimensional/position_word.rb
word_search-0.1.0 lib/word_search/two_dimensional/position_word.rb