Class: WordSearch::Generator

Inherits:
SimpleDelegator
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/word_search/generator.rb,
lib/word_search/generator/base.rb

Defined Under Namespace

Classes: Base

Instance Method Summary collapse

Constructor Details

#initialize(file, x, y, z = nil) ⇒ Generator

Returns a new instance of Generator.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/word_search/generator.rb', line 11

def initialize(file, x, y, z = nil)
  plane = Plane.make_from_coordinates(x, y, z)
  obj =
    if z.present?
      ThreeDimensional::Generator.new(plane, WordBank.new(file))
    else
      TwoDimensional::Generator.new(plane, WordBank.new(file))
    end

  super obj
end

Instance Method Details

#objectObject



34
35
36
# File 'lib/word_search/generator.rb', line 34

def object
  __getobj__
end

#performObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/word_search/generator.rb', line 23

def perform
  super

  if valid?
    plane.add_letters
    plane
  else
    false
  end
end