Sha256: ee241b044af0c83337d27158ab7d00857dac0b6aa6d78a194c93b14d2922d2d0
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module WordSearch class Plane class Base < Hash include ActiveModel::Validations LETTERS = ("a".."z").to_a attr_accessor :x, :y, :catalog validates :x, :y, numericality: { greater_than_or_equal_to: 2 } def print(file_name = nil) File.open(file_name || "word_search", "w") { |f| f.write to_s } end def random_letter LETTERS.sample end def two_dimensional? true end def three_dimensional? false end def add_letters x.times do |x_point| y.times do |y_point| yield(x_point, y_point) end end end def pto_s puts to_s end def digest Digest::MD5.hexdigest(to_s) end def to_s raise NotImplementedError end def total_points raise NotImplementedError end def max raise NotImplementedError end def directions raise NotImplementedError end private def initialize_plane x.times do |x_point| self[x_point] = {} y.times do |y_point| yield(x_point, y_point) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
word_search-1.0.1 | lib/word_search/plane/base.rb |
word_search-1.0.0 | lib/word_search/plane/base.rb |