Class: Vedeu::IndexPosition

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

Overview

Converts an index into a position for the terminal.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Parameters:



23
24
25
26
# File 'lib/vedeu/output/index_position.rb', line 23

def initialize(y, x)
  @y = (y <= 0) ? 1 : (y + 1)
  @x = (x <= 0) ? 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/index_position.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/index_position.rb', line 7

def y
  @y
end

Class Method Details

.[](y, x) ⇒ Array

Parameters:

Returns:

  • (Array)


16
17
18
# File 'lib/vedeu/output/index_position.rb', line 16

def self.[](y, x)
  new(y, x).[]
end

Instance Method Details

#[]Array

Returns:

  • (Array)


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

def []
  [y, x]
end