Class: Snuffle::Formatters::HtmlIndex

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/snuffle/formatters/html_index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

#columns, #export, #file_extension, included, #output_path, #path_to_results, #root_path

Constructor Details

#initialize(summaries, start_path) ⇒ HtmlIndex

Returns a new instance of HtmlIndex.



10
11
12
13
# File 'lib/snuffle/formatters/html_index.rb', line 10

def initialize(summaries, start_path)
  self.summaries = summaries.sort{|a,b| a.cohorts.count <=> b.cohorts.count}.reverse
  self.start_path = start_path
end

Instance Attribute Details

#start_pathObject

Returns the value of attribute start_path.



8
9
10
# File 'lib/snuffle/formatters/html_index.rb', line 8

def start_path
  @start_path
end

#summariesObject

Returns the value of attribute summaries.



8
9
10
# File 'lib/snuffle/formatters/html_index.rb', line 8

def summaries
  @summaries
end

Instance Method Details

#contentObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/snuffle/formatters/html_index.rb', line 19

def content
  Haml::Engine.new(output_template).render(
    Object.new, {
      summaries: self.summaries,
      start_path: self.start_path,
      date: Time.now.strftime("%Y/%m/%d"),
      time: Time.now.strftime("%l:%M %P")
    }
  )
end

#filenameObject



30
31
32
# File 'lib/snuffle/formatters/html_index.rb', line 30

def filename
  "index.htm"
end

#headerObject



15
16
17
# File 'lib/snuffle/formatters/html_index.rb', line 15

def header
  ["File", "Class", "Object Candidates"].map{|col| "<th>#{col.titleize}</th>"}.join("\r\n")
end

#output_templateObject



34
35
36
# File 'lib/snuffle/formatters/html_index.rb', line 34

def output_template
  File.read(File.dirname(__FILE__) + "/templates/index.html.haml")
end