Class: Vedeu::Geometry::Grid
- Inherits:
-
Object
- Object
- Vedeu::Geometry::Grid
- 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
- #value ⇒ Fixnum readonly protected
Class Method Summary collapse
Instance Method Summary collapse
-
#column ⇒ Fixnum
private
Returns the width of a single column in characters.
- #columns ⇒ Object
-
#initialize(value) ⇒ Vedeu::Geometry::Grid
constructor
Returns a new instance of Vedeu::Geometry::Grid.
-
#out_of_range? ⇒ Boolean
private
Returns a boolean indicating whether the value is out of range.
-
#row ⇒ Fixnum
private
Returns the height of a single row in characters.
- #rows ⇒ Object
Constructor Details
#initialize(value) ⇒ Vedeu::Geometry::Grid
Returns a new instance of Vedeu::Geometry::Grid.
28 29 30 |
# File 'lib/vedeu/geometry/grid.rb', line 28 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Fixnum (readonly, protected)
50 51 52 |
# File 'lib/vedeu/geometry/grid.rb', line 50 def value @value end |
Class Method Details
.columns(value) ⇒ Object
14 15 16 |
# File 'lib/vedeu/geometry/grid.rb', line 14 def self.columns(value) new(value).columns end |
.rows(value) ⇒ Object
20 21 22 |
# File 'lib/vedeu/geometry/grid.rb', line 20 def self.rows(value) new(value).rows end |
Instance Method Details
#column ⇒ Fixnum (private)
Returns the width of a single column in characters.
72 73 74 |
# File 'lib/vedeu/geometry/grid.rb', line 72 def column Vedeu.width / 12 end |
#columns ⇒ Object
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.
65 66 67 |
# File 'lib/vedeu/geometry/grid.rb', line 65 def out_of_range? value < 1 || value > 12 end |
#row ⇒ Fixnum (private)
Returns the height of a single row in characters.
57 58 59 |
# File 'lib/vedeu/geometry/grid.rb', line 57 def row Vedeu.height / 12 end |
#rows ⇒ Object
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 |