Class: Veye::Project::InfoMarkdown

Inherits:
BaseMarkdown show all
Defined in:
lib/veye/views/project/info_markdown.rb

Instance Method Summary collapse

Methods inherited from BaseMarkdown

#after, #before

Constructor Details

#initializeInfoMarkdown

Returns a new instance of InfoMarkdown.



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

def initialize
  headings  = %w(index name project_id project_type public period source dependencies outdated created)
  super("Project's information", headings)
end

Instance Method Details

#format(results) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/veye/views/project/info_markdown.rb', line 11

def format(results)
  return if results.nil?

  results = [results] if results.is_a?(Hash) #required for  `project show`
  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
 
    @table << [
      (index + 1).to_s,
      result["name"],
      result["id"],
      result["project_type"],
      result["public"].to_s,
      result["period"],
      result["source"],
      result["dep_number"].to_s,
      result["out_number"].to_s,
      result["created_at"]
    ]
  end
end