Sha256: 055bc6d5e6d5cd08301a91922e325c8b4d6060e46b47bdf71afe473ccb21f119
Contents?: true
Size: 794 Bytes
Versions: 3
Compression:
Stored size: 794 Bytes
Contents
# frozen_string_literal: true 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 def document_position(letter, index) positions.merge!("#{letter}-#{index}" => { x: coordinate.x, y: coordinate.y }) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems