Sha256: d0ba7be296388ccf0020299c65019de849b7bebcf30b8426fa41531958145c80

Contents?: true

Size: 755 Bytes

Versions: 3

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

module WordSearch
  class Plane < SimpleDelegator
    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

    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

    def to_s
      if invalid?
        errors.full_messages.join("\n")
      else
        super
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
word_search-1.3.0 lib/word_search/plane.rb
word_search-1.2.1 lib/word_search/plane.rb
word_search-1.2.0 lib/word_search/plane.rb