Class: Vedeu::PositionIndex
- Inherits:
-
Object
- Object
- Vedeu::PositionIndex
- Defined in:
- lib/vedeu/output/position_index.rb
Overview
Converts a position into an index for the terminal.
Instance Attribute Summary collapse
-
#x ⇒ Object
(also: #last)
readonly
Returns the value of attribute x.
-
#y ⇒ Object
(also: #first)
readonly
Returns the value of attribute y.
Class Method Summary collapse
Instance Method Summary collapse
- #[] ⇒ Array
- #initialize(y, x) ⇒ Vedeu::PositionIndex constructor
Constructor Details
#initialize(y, x) ⇒ Vedeu::PositionIndex
23 24 25 26 |
# File 'lib/vedeu/output/position_index.rb', line 23 def initialize(y, x) @y = ((y - 1) <= 1) ? 1 : (y - 1) @x = ((x - 1) <= 1) ? 1 : (x - 1) end |
Instance Attribute Details
#x ⇒ Object (readonly) Also known as: last
Returns the value of attribute x.
7 8 9 |
# File 'lib/vedeu/output/position_index.rb', line 7 def x @x end |
#y ⇒ Object (readonly) Also known as: first
Returns the value of attribute y.
7 8 9 |
# File 'lib/vedeu/output/position_index.rb', line 7 def y @y end |
Class Method Details
.[](y, x) ⇒ Array
16 17 18 |
# File 'lib/vedeu/output/position_index.rb', line 16 def self.[](y, x) new(y, x).[] end |
Instance Method Details
#[] ⇒ Array
29 30 31 |
# File 'lib/vedeu/output/position_index.rb', line 29 def [] [y, x] end |