Class: TablePrint::RowGroup
- Inherits:
-
Object
- Object
- TablePrint::RowGroup
- Includes:
- RowRecursion
- Defined in:
- lib/table_print/row_group.rb
Instance Attribute Summary
Attributes included from RowRecursion
Instance Method Summary collapse
- #collapse! ⇒ Object
-
#format ⇒ Object
TODO: rename this to_s.
-
#initialize ⇒ RowGroup
constructor
A new instance of RowGroup.
- #raw_column_data(column_name) ⇒ Object
- #raw_column_names ⇒ Object
- #skip_first_row! ⇒ Object
-
#vis(prefix = "") ⇒ Object
this is a development tool, to show the structure of the row/row_group tree.
Methods included from RowRecursion
#add_child, #add_children, #add_formatter, #child_count, #column_count, #column_for, #columns, #header, #horizontal_separator, #insert_children, #set_column, #width
Constructor Details
#initialize ⇒ RowGroup
Returns a new instance of RowGroup.
91 92 93 94 |
# File 'lib/table_print/row_group.rb', line 91 def initialize super @skip_first_row = false end |
Instance Method Details
#collapse! ⇒ Object
111 112 113 |
# File 'lib/table_print/row_group.rb', line 111 def collapse! @children.each(&:collapse!) end |
#format ⇒ Object
TODO: rename this to_s
116 117 118 119 120 121 122 123 124 |
# File 'lib/table_print/row_group.rb', line 116 def format rows = @children rows = @children[1..-1] if @skip_first_row rows ||= [] rows = rows.collect { |row| row.format }.join("\n") return nil if rows.length == 0 rows end |
#raw_column_data(column_name) ⇒ Object
96 97 98 |
# File 'lib/table_print/row_group.rb', line 96 def raw_column_data(column_name) @children.collect { |r| r.raw_column_data(column_name) }.flatten end |
#raw_column_names ⇒ Object
100 101 102 103 |
# File 'lib/table_print/row_group.rb', line 100 def raw_column_names return @raw_column_names if @raw_column_names @raw_column_names = @children.collect { |r| r.raw_column_names }.flatten.uniq end |
#skip_first_row! ⇒ Object
126 127 128 |
# File 'lib/table_print/row_group.rb', line 126 def skip_first_row! @skip_first_row = true end |
#vis(prefix = "") ⇒ Object
this is a development tool, to show the structure of the row/row_group tree
106 107 108 109 |
# File 'lib/table_print/row_group.rb', line 106 def vis(prefix="") puts "#{prefix}group" children.each{|c| c.vis(prefix + " ")} end |