Class: Snuffle::Formatters::HtmlIndex
- Inherits:
-
Object
- Object
- Snuffle::Formatters::HtmlIndex
- Includes:
- Base
- Defined in:
- lib/snuffle/formatters/html_index.rb
Instance Attribute Summary collapse
-
#start_path ⇒ Object
Returns the value of attribute start_path.
-
#summaries ⇒ Object
Returns the value of attribute summaries.
Instance Method Summary collapse
- #content ⇒ Object
- #filename ⇒ Object
- #header ⇒ Object
-
#initialize(summaries, start_path) ⇒ HtmlIndex
constructor
A new instance of HtmlIndex.
- #output_template ⇒ Object
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_path ⇒ Object
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 |
#summaries ⇒ Object
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
#content ⇒ Object
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 |
#filename ⇒ Object
30 31 32 |
# File 'lib/snuffle/formatters/html_index.rb', line 30 def filename "index.htm" end |
#header ⇒ Object
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_template ⇒ Object
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 |