Class: Fukuzatsu::Formatters::HtmlIndex
- Inherits:
-
Object
- Object
- Fukuzatsu::Formatters::HtmlIndex
show all
- Includes:
- Base
- Defined in:
- lib/fukuzatsu/formatters/html_index.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Base
included, #output_directory, #path_to_results
Constructor Details
#initialize(summaries, base_output_path) ⇒ HtmlIndex
Returns a new instance of HtmlIndex.
11
12
13
14
|
# File 'lib/fukuzatsu/formatters/html_index.rb', line 11
def initialize(summaries, base_output_path)
@summaries = summaries
@base_output_path = base_output_path
end
|
Instance Attribute Details
#summaries ⇒ Object
Returns the value of attribute summaries.
9
10
11
|
# File 'lib/fukuzatsu/formatters/html_index.rb', line 9
def summaries
@summaries
end
|
Instance Method Details
#content ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/fukuzatsu/formatters/html_index.rb', line 16
def content
Haml::Engine.new(output_template).render(
Object.new, {
summaries: summaries,
date: Time.now.strftime("%Y/%m/%d"),
time: Time.now.strftime("%l:%M %P")
}
)
end
|
#export ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/fukuzatsu/formatters/html_index.rb', line 26
def export
begin
File.open(path_to_results, 'w') {|outfile| outfile.write(content)}
rescue Exception => e
puts "Unable to write output: #{e} #{e.backtrace}"
end
end
|
#file_extension ⇒ Object
38
39
40
|
# File 'lib/fukuzatsu/formatters/html_index.rb', line 38
def file_extension
".htm"
end
|
#filename ⇒ Object
34
35
36
|
# File 'lib/fukuzatsu/formatters/html_index.rb', line 34
def filename
"index.htm"
end
|
#output_path ⇒ Object
42
43
44
45
|
# File 'lib/fukuzatsu/formatters/html_index.rb', line 42
def output_path
FileUtils.mkpath(self.output_directory)
self.output_directory
end
|
#output_template ⇒ Object
47
48
49
|
# File 'lib/fukuzatsu/formatters/html_index.rb', line 47
def output_template
File.read(File.dirname(__FILE__) + "/templates/index.html.haml")
end
|