Class: Charty::ArrayLayout
- Inherits:
-
Object
- Object
- Charty::ArrayLayout
- Defined in:
- lib/charty/layout.rb
Instance Method Summary collapse
- #<<(content) ⇒ Object
-
#initialize(direction = :horizontal) ⇒ ArrayLayout
constructor
A new instance of ArrayLayout.
- #num_cols ⇒ Object
- #num_rows ⇒ Object
- #rows ⇒ Object
Constructor Details
#initialize(direction = :horizontal) ⇒ ArrayLayout
Returns a new instance of ArrayLayout.
38 39 40 41 |
# File 'lib/charty/layout.rb', line 38 def initialize(direction=:horizontal) @array = [] @direction = direction end |
Instance Method Details
#<<(content) ⇒ Object
43 44 45 |
# File 'lib/charty/layout.rb', line 43 def <<(content) @array << content end |
#num_cols ⇒ Object
51 52 53 |
# File 'lib/charty/layout.rb', line 51 def num_cols @direction == :vertical ? 1 : @array.count end |
#num_rows ⇒ Object
47 48 49 |
# File 'lib/charty/layout.rb', line 47 def num_rows @direction == :horizontal ? 1 : @array.count end |
#rows ⇒ Object
55 56 57 |
# File 'lib/charty/layout.rb', line 55 def rows [@array] end |