Class: Doku::SquareOnGrid
- Inherits:
-
Struct
- Object
- Struct
- Doku::SquareOnGrid
- Defined in:
- lib/doku/grid.rb
Overview
Represents a square on a grid. Any two instances with the same x and y coordinates are considered to be equal, which makes it convenient to use SquareOnGrid instances as a key in a hash table. This class is used by the PuzzleOnGrid module to represent the squares in grid-based Puzzles.
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
-
#matches?(conditions) ⇒ Boolean
True if the square matches all the conditions.
- #to_s ⇒ Object
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x
229 230 231 |
# File 'lib/doku/grid.rb', line 229 def x @x end |
#y ⇒ Object
Returns the value of attribute y
229 230 231 |
# File 'lib/doku/grid.rb', line 229 def y @y end |
Instance Method Details
#matches?(conditions) ⇒ Boolean
Returns True if the square matches all the conditions.
233 234 235 |
# File 'lib/doku/grid.rb', line 233 def matches?(conditions) conditions.all? { |property, values| values === send(property) } end |
#to_s ⇒ Object
237 238 239 |
# File 'lib/doku/grid.rb', line 237 def to_s "Square(#{x}, #{y})" end |