Class: Vedeu::HTMLRenderer
- Inherits:
-
Object
- Object
- Vedeu::HTMLRenderer
- Defined in:
- lib/vedeu/output/html_renderer.rb
Overview
Renders a VirtualBuffer or Output as a HTML table.
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
private
Returns the value of attribute output.
Class Method Summary collapse
Instance Method Summary collapse
- #file_path ⇒ String private
- #html_body ⇒ String
- #initialize(output) ⇒ Vedeu::HTMLRenderer constructor
- #render ⇒ String
- #template ⇒ String private
-
#timestamp ⇒ Object
private
return [Fixnum].
-
#to_file(path = file_path) ⇒ String
Writes the parsed template to a file (at the given path) and returns the contents.
Constructor Details
#initialize(output) ⇒ Vedeu::HTMLRenderer
21 22 23 |
# File 'lib/vedeu/output/html_renderer.rb', line 21 def initialize(output) @output = output end |
Instance Attribute Details
#output ⇒ Object (readonly, private)
Returns the value of attribute output.
59 60 61 |
# File 'lib/vedeu/output/html_renderer.rb', line 59 def output @output end |
Class Method Details
.render(output) ⇒ String
9 10 11 |
# File 'lib/vedeu/output/html_renderer.rb', line 9 def self.render(output) new(output).render end |
.to_file(output) ⇒ String
15 16 17 |
# File 'lib/vedeu/output/html_renderer.rb', line 15 def self.to_file(output) new(output).to_file end |
Instance Method Details
#file_path ⇒ String (private)
67 68 69 |
# File 'lib/vedeu/output/html_renderer.rb', line 67 def file_path "/tmp/vedeu_html_#{}.html" end |
#html_body ⇒ String
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/vedeu/output/html_renderer.rb', line 44 def html_body out = '' Array(output).each do |line| out << "<tr>\n" line.each do |char| out << char.to_html out << "\n" end out << "</tr>\n" end out end |
#render ⇒ String
26 27 28 |
# File 'lib/vedeu/output/html_renderer.rb', line 26 def render Template.parse(self, template) end |
#template ⇒ String (private)
62 63 64 |
# File 'lib/vedeu/output/html_renderer.rb', line 62 def template File.dirname(__FILE__) + '/templates/html_renderer.vedeu' end |
#timestamp ⇒ Object (private)
return [Fixnum]
72 73 74 |
# File 'lib/vedeu/output/html_renderer.rb', line 72 def @timestamp ||= Time.now.to_i end |
#to_file(path = file_path) ⇒ String
Writes the parsed template to a file (at the given path) and returns the contents.
35 36 37 38 39 40 41 |
# File 'lib/vedeu/output/html_renderer.rb', line 35 def to_file(path = file_path) content = render File.open(path, "w", 0644) { |file| file.write(content) } content end |