Class: Veye::Project::InfoTable

Inherits:
BaseTable show all
Defined in:
lib/veye/views/project/info_table.rb

Instance Method Summary collapse

Methods inherited from BaseTable

#after, #before

Constructor Details

#initializeInfoTable

Returns a new instance of InfoTable.



6
7
8
9
# File 'lib/veye/views/project/info_table.rb', line 6

def initialize
  headings = %w(index name project_id public period source dependencies outdated created_at)
  super("List of projects", headings)
end

Instance Method Details

#format(results) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/veye/views/project/info_table.rb', line 11

def format(results)
  return if results.nil?
  results = [results] if results.is_a? Hash

  results.each_with_index do |result, index|
    #BUG: API returns raw mongoID value as id when fetching a list of projects
    if result['id'].is_a?(Hash)
      result['id'] = result['id'].values.first 
    end

    row = [index + 1, result['name'], result['id'],
           result['public'], result['period'], result['source'],
           result['dep_number'], result['out_number'], result['created_at']]
    @table << row
   end
end