Class: WordSearch::Plane::Base
- Inherits:
-
Hash
- Object
- Hash
- WordSearch::Plane::Base
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/word_search/plane/base.rb
Constant Summary collapse
- LETTERS =
("a".."z").to_a
Instance Attribute Summary collapse
-
#catalog ⇒ Object
Returns the value of attribute catalog.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #add_letters ⇒ Object
- #directions ⇒ Object
- #letter_at(*positions) ⇒ Object
- #max ⇒ Object
- #print(file_name = nil) ⇒ Object
- #pto_s ⇒ Object
- #random_letter ⇒ Object
- #three_dimensional? ⇒ Boolean
- #to_s ⇒ Object
- #total_points ⇒ Object
- #two_dimensional? ⇒ Boolean
Instance Attribute Details
#catalog ⇒ Object
Returns the value of attribute catalog.
10 11 12 |
# File 'lib/word_search/plane/base.rb', line 10 def catalog @catalog end |
#x ⇒ Object
Returns the value of attribute x.
10 11 12 |
# File 'lib/word_search/plane/base.rb', line 10 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
10 11 12 |
# File 'lib/word_search/plane/base.rb', line 10 def y @y end |
Instance Method Details
#add_letters ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/word_search/plane/base.rb', line 30 def add_letters x.times do |x_point| y.times do |y_point| yield(x_point, y_point) end end end |
#directions ⇒ Object
54 55 56 |
# File 'lib/word_search/plane/base.rb', line 54 def directions raise NotImplementedError end |
#letter_at(*positions) ⇒ Object
58 59 60 |
# File 'lib/word_search/plane/base.rb', line 58 def letter_at(*positions) dig(*positions) end |
#max ⇒ Object
50 51 52 |
# File 'lib/word_search/plane/base.rb', line 50 def max raise NotImplementedError end |
#print(file_name = nil) ⇒ Object
14 15 16 |
# File 'lib/word_search/plane/base.rb', line 14 def print(file_name = nil) File.open(file_name || "word_search", "w") { |f| f.write to_s } end |
#pto_s ⇒ Object
38 39 40 |
# File 'lib/word_search/plane/base.rb', line 38 def pto_s puts to_s end |
#random_letter ⇒ Object
18 19 20 |
# File 'lib/word_search/plane/base.rb', line 18 def random_letter LETTERS.sample end |
#three_dimensional? ⇒ Boolean
26 27 28 |
# File 'lib/word_search/plane/base.rb', line 26 def three_dimensional? false end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/word_search/plane/base.rb', line 42 def to_s raise NotImplementedError end |
#total_points ⇒ Object
46 47 48 |
# File 'lib/word_search/plane/base.rb', line 46 def total_points raise NotImplementedError end |
#two_dimensional? ⇒ Boolean
22 23 24 |
# File 'lib/word_search/plane/base.rb', line 22 def two_dimensional? true end |