Class: Charty::GridLayout
- Inherits:
-
Object
- Object
- Charty::GridLayout
- Defined in:
- lib/charty/layout.rb
Instance Attribute Summary collapse
-
#num_cols ⇒ Object
readonly
Returns the value of attribute num_cols.
-
#num_rows ⇒ Object
readonly
Returns the value of attribute num_rows.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #<<(content) ⇒ Object
-
#initialize(num_cols, num_rows) ⇒ GridLayout
constructor
A new instance of GridLayout.
Constructor Details
#initialize(num_cols, num_rows) ⇒ GridLayout
Returns a new instance of GridLayout.
63 64 65 66 67 68 |
# File 'lib/charty/layout.rb', line 63 def initialize(num_cols, num_rows) @rows = Array.new(num_rows) { Array.new(num_cols) } @num_cols = num_cols @num_rows = num_rows @cursor = 0 end |
Instance Attribute Details
#num_cols ⇒ Object (readonly)
Returns the value of attribute num_cols.
61 62 63 |
# File 'lib/charty/layout.rb', line 61 def num_cols @num_cols end |
#num_rows ⇒ Object (readonly)
Returns the value of attribute num_rows.
61 62 63 |
# File 'lib/charty/layout.rb', line 61 def num_rows @num_rows end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
61 62 63 |
# File 'lib/charty/layout.rb', line 61 def rows @rows end |
Instance Method Details
#<<(content) ⇒ Object
70 71 72 73 |
# File 'lib/charty/layout.rb', line 70 def <<(content) @rows[@cursor / @num_rows][@cursor % @num_cols] = content @cursor += 1 end |