Class: Vedeu::Geometry::Grid

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/geometry/grid.rb

Overview

The grid system splits the terminal height and width into 12 equal parts, by dividing the available height and width by 12. If the terminal height or width is not a multiple of 12, then Grid chooses the maximum value which will fit.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Vedeu::Geometry::Grid

Returns a new instance of Vedeu::Geometry::Grid.

Parameters:

  • value (Fixnum)


28
29
30
# File 'lib/vedeu/geometry/grid.rb', line 28

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueFixnum (readonly, protected)

Returns:

  • (Fixnum)


50
51
52
# File 'lib/vedeu/geometry/grid.rb', line 50

def value
  @value
end

Class Method Details

.columns(value) ⇒ Object

See Also:



14
15
16
# File 'lib/vedeu/geometry/grid.rb', line 14

def self.columns(value)
  new(value).columns
end

.rows(value) ⇒ Object

See Also:



20
21
22
# File 'lib/vedeu/geometry/grid.rb', line 20

def self.rows(value)
  new(value).rows
end

Instance Method Details

#columnFixnum (private)

Returns the width of a single column in characters.

Returns:

  • (Fixnum)


72
73
74
# File 'lib/vedeu/geometry/grid.rb', line 72

def column
  Vedeu.width / 12
end

#columnsObject

See Also:



33
34
35
36
37
# File 'lib/vedeu/geometry/grid.rb', line 33

def columns
  fail Vedeu::Error::OutOfRange if out_of_range?

  column * value
end

#out_of_range?Boolean (private)

Returns a boolean indicating whether the value is out of range.

Returns:

  • (Boolean)


65
66
67
# File 'lib/vedeu/geometry/grid.rb', line 65

def out_of_range?
  value < 1 || value > 12
end

#rowFixnum (private)

Returns the height of a single row in characters.

Returns:

  • (Fixnum)


57
58
59
# File 'lib/vedeu/geometry/grid.rb', line 57

def row
  Vedeu.height / 12
end

#rowsObject

See Also:



40
41
42
43
44
# File 'lib/vedeu/geometry/grid.rb', line 40

def rows
  fail Vedeu::Error::OutOfRange if out_of_range?

  row * value
end