Class: PrettyTable
- Inherits:
-
Object
- Object
- PrettyTable
- Defined in:
- lib/pretty_table.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#initialize(data = [], headers = []) ⇒ PrettyTable
constructor
A new instance of PrettyTable.
- #to_s ⇒ Object
Constructor Details
#initialize(data = [], headers = []) ⇒ PrettyTable
Returns a new instance of PrettyTable.
4 5 6 7 |
# File 'lib/pretty_table.rb', line 4 def initialize(data = [], headers = []) @data = data @headers = headers end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
2 3 4 |
# File 'lib/pretty_table.rb', line 2 def data @data end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
2 3 4 |
# File 'lib/pretty_table.rb', line 2 def headers @headers end |
Instance Method Details
#to_s ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pretty_table.rb', line 9 def to_s string = '' string << header_cells.join(' | ') string << "\n" string << divider_cells.join('-+-') string << "\n" data_rows.each do |data_cells| string << data_cells.join(' | ') string << "\n" end string end |