Class: Docwatch::Renderer
- Inherits:
-
Object
- Object
- Docwatch::Renderer
- Defined in:
- lib/docwatch/renderer.rb
Defined Under Namespace
Constant Summary collapse
- @@extensions =
{}
Class Method Summary collapse
- .by_filetype(file_path) ⇒ Object
-
.extension(sym) ⇒ Object
Set an extension (by symbol) as being supported by this class.
Instance Method Summary collapse
-
#initialize(file_path) ⇒ Renderer
constructor
A new instance of Renderer.
- #js ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(file_path) ⇒ Renderer
Returns a new instance of Renderer.
17 18 19 |
# File 'lib/docwatch/renderer.rb', line 17 def initialize(file_path) @file_path = file_path end |
Class Method Details
.by_filetype(file_path) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/docwatch/renderer.rb', line 10 def self.by_filetype(file_path) extname = File.extname(file_path)[1..] return if extname.length == 0 @@extensions[extname.to_sym].first.new(file_path) end |
.extension(sym) ⇒ Object
Set an extension (by symbol) as being supported by this class.
6 7 8 |
# File 'lib/docwatch/renderer.rb', line 6 def self.extension(sym) (@@extensions[sym] ||= []) << self end |
Instance Method Details
#js ⇒ Object
21 22 23 |
# File 'lib/docwatch/renderer.rb', line 21 def js File.read(Docwatch.root_dir + '/res/inject.js') end |
#to_html ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/docwatch/renderer.rb', line 25 def to_html return " <!doctype html>\n <html>\n <head>\n \#{head}\n </head>\n <body>\n \#{body}\n <script>\n (function() {\n \#{js}\n })()\n </script>\n </body>\n </html>\n EOF\nend\n" |