Module: Crucigrama::Positionable
- Included in:
- Crossword, CrosswordBuilder
- Defined in:
- lib/crucigrama/positionable.rb
Overview
This module defines some methods of use to interact with Crosswords
Instance Method Summary collapse
-
#direction_other_than(direction) ⇒ Symbol?
The direction opposite to the one given, that is, :horizontal for :vertical and :vertical for :horizontal; or nil if neither :horizontal nor :vertical is provided as direction.
-
#position(x, y) ⇒ Hash<Symbol,Integer>
A hash with the horizontal and vertical coordinates.
Instance Method Details
#direction_other_than(direction) ⇒ Symbol?
Returns the direction opposite to the one given, that is, :horizontal for :vertical and :vertical for :horizontal; or nil if neither :horizontal nor :vertical is provided as direction.
16 17 18 |
# File 'lib/crucigrama/positionable.rb', line 16 def direction_other_than(direction) { :horizontal => :vertical, :vertical => :horizontal}[direction] end |
#position(x, y) ⇒ Hash<Symbol,Integer>
Returns a hash with the horizontal and vertical coordinates.
7 8 9 |
# File 'lib/crucigrama/positionable.rb', line 7 def position(x,y) {:horizontal => x, :vertical => y} end |