Class: Vedeu::PositionIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/output/position_index.rb

Overview

Converts a position into an index for the terminal.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(y, x) ⇒ Vedeu::PositionIndex

Parameters:



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

#xObject (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

#yObject (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

Parameters:

Returns:

  • (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

Returns:

  • (Array)


29
30
31
# File 'lib/vedeu/output/position_index.rb', line 29

def []
  [y, x]
end