Class: Hirb::Helpers::TabTable

Inherits:
Table
  • Object
show all
Defined in:
lib/hirb/helpers/tab_table.rb

Constant Summary collapse

DELIM =
"\t"

Constants inherited from Table

Hirb::Helpers::Table::BORDER_LENGTH, Hirb::Helpers::Table::CHARS, Hirb::Helpers::Table::MIN_FIELD_LENGTH

Instance Attribute Summary

Attributes inherited from Table

#field_lengths, #fields, #max_fields, #width

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Table

#actual_width, #array_to_indices_hash, #call_filter, #chars, #default_field_lengths, #enforce_field_constraints, #filter_values, #format_cell, #format_values, #initialize, #render, #render_border, #render_table_description, #set_fields, #set_filter_defaults, #set_headers, #set_rows, #setup_field_lengths, #validate_values

Constructor Details

This class inherits a constructor from Hirb::Helpers::Table

Class Method Details

.render(rows, options = {}) ⇒ Object

Renders a tab-delimited table



5
6
7
# File 'lib/hirb/helpers/tab_table.rb', line 5

def self.render(rows, options={})
  new(rows, {:description => false}.merge(options)).render
end

Instance Method Details



21
22
23
# File 'lib/hirb/helpers/tab_table.rb', line 21

def render_footer
  []
end

#render_headerObject



9
10
11
# File 'lib/hirb/helpers/tab_table.rb', line 9

def render_header
  @headers ? render_table_header : []
end

#render_rowsObject



17
18
19
# File 'lib/hirb/helpers/tab_table.rb', line 17

def render_rows
  @rows.map { |row| format_values(row).join(DELIM) }
end

#render_table_headerObject



13
14
15
# File 'lib/hirb/helpers/tab_table.rb', line 13

def render_table_header
  [ format_values(@headers).join(DELIM) ]
end