Class: Dir2D
Constant Summary
collapse
- N =
UP = Dir2D.new( 0, -1)
- E =
RIGHT = Dir2D.new( 1, 0)
- S =
DOWN = Dir2D.new( 0, 1)
- W =
LEFT = Dir2D.new(-1, 0)
Instance Attribute Summary
Attributes inherited from Point2D
#x, #y
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Point2D
#+, #-, #<=>, #==, #area, #dist, #flip, from_dir_bitmask, from_s, #left, #left!, #manhattan, #max, #min, #minmax, minmax, #to_dir_bitmask, #to_s
Class Method Details
.hori(length = 1) ⇒ Object
233
234
235
|
# File 'lib/cem/cruzzles.rb', line 233
def self.hori(length=1)
return [E * (1..length), W * (1..length)].flatten
end
|
.vert(length = 1) ⇒ Object
229
230
231
|
# File 'lib/cem/cruzzles.rb', line 229
def self.vert(length=1)
return [N * (1..length), S * (1..length)].flatten
end
|
.x(length = 1) ⇒ Object
237
238
239
|
# File 'lib/cem/cruzzles.rb', line 237
def self.x(length=1)
return vert(length) + hori(length)
end
|
Instance Method Details
#*(other) ⇒ Object
Dir2D * Range = array of Dir2D E * (1..3) = [E, E*2, E*3]
221
222
223
224
225
226
227
|
# File 'lib/cem/cruzzles.rb', line 221
def *(other)
if other.is_a? Range
other.to_a.map { |b| self * b }
else
super
end
end
|