Method: Apollo::Formatter::TableFormatter.format
- Defined in:
- lib/apollo_crawler/formatter/table_formatter.rb
.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 |