Class: Conjure::View::TableView
- Inherits:
-
Object
- Object
- Conjure::View::TableView
- Defined in:
- lib/conjure/view/table_view.rb
Instance Method Summary collapse
-
#initialize(data) ⇒ TableView
constructor
A new instance of TableView.
- #render ⇒ Object
Constructor Details
#initialize(data) ⇒ TableView
Returns a new instance of TableView.
4 5 6 7 |
# File 'lib/conjure/view/table_view.rb', line 4 def initialize(data) @data = data calculate_widths end |
Instance Method Details
#render ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/conjure/view/table_view.rb', line 9 def render rows = [@width.map{|col, width| pad_to_width(col, width)}.join(column_separator)] rows += @data.map do |row| @width.map{|col, width| pad_to_width(row[col], width)}.join(column_separator) end rows.join("\n") end |