Sha256: d5bf234a3e906f4668d82df620c57146d965886524aa1356c19e82951389b5a4

Contents?: true

Size: 914 Bytes

Versions: 3

Compression:

Stored size: 914 Bytes

Contents

# frozen_string_literal: true

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

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

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

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

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

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

      def document_position(letter, index)
        positions.merge!("#{letter}-#{index}" => {
          x: coordinate.x, y: coordinate.y, z: coordinate.z
        })
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
word_search-1.3.0 lib/word_search/three_dimensional/position_word.rb
word_search-1.2.1 lib/word_search/three_dimensional/position_word.rb
word_search-1.2.0 lib/word_search/three_dimensional/position_word.rb