class WordSearch::Plane

Public Class Methods

make_from_coordinates(x, y, z = nil) click to toggle source
# File lib/word_search/plane.rb, line 19
def self.make_from_coordinates(x, y, z = nil)
  obj =
    if z.present? && z > 1
      ThreeDimensional::Plane.new(x, y, z)
    else
      TwoDimensional::Plane.new(x, y)
    end

  new(obj)
end
make_from_file(file, should_catalog: true) click to toggle source
# File lib/word_search/plane.rb, line 5
def self.make_from_file(file, should_catalog: true)
  dimension =
    if File.read(file).split("\n\n").count > 1
      ThreeDimensional
    else
      TwoDimensional
    end

  obj =
    dimension::Plane.make_from_file(file, should_catalog: should_catalog)

  new(obj)
end

Public Instance Methods

to_s() click to toggle source
Calls superclass method
# File lib/word_search/plane.rb, line 30
def to_s
  if invalid?
    errors.full_messages.join("\n")
  else
    super
  end
end