Class: Apollo::Formatter::TableFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- Apollo::Formatter::TableFormatter
- Defined in:
- lib/apollo_crawler/formatter/table_formatter.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BaseFormatter
Class Method Details
.format(obj) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/apollo_crawler/formatter/table_formatter.rb', line 36 def self.format(obj) headings = [] if(obj[:data].length > 0) headings = obj[:data][0].keys end rows = [] obj[:data].each do |line| next if (line.nil? || line.empty?) data = [] headings.each do |column| data << line[column] end rows << data end table = Terminal::Table.new :headings => headings, :rows => rows return table end |
Instance Method Details
#format(obj) ⇒ Object
32 33 34 |
# File 'lib/apollo_crawler/formatter/table_formatter.rb', line 32 def format(obj) return Table.format(obj) end |
#name ⇒ Object
28 29 30 |
# File 'lib/apollo_crawler/formatter/table_formatter.rb', line 28 def name() return "Table" end |