class Docwatch::Renderer

Public Class Methods

by_filetype(file_path) click to toggle source
# 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) click to toggle source

Set an extension (by symbol) as being supported by this class.

# File lib/docwatch/renderer.rb, line 6
def self.extension(sym)
    (@@extensions[sym] ||= []) << self
end
new(file_path) click to toggle source
# File lib/docwatch/renderer.rb, line 16
def initialize(file_path)
    @file_path = file_path
end

Public Instance Methods

js() click to toggle source
# File lib/docwatch/renderer.rb, line 20
def js
    File.read(Docwatch.root_dir + '/res/inject.js')
end
to_html() click to toggle source
# File lib/docwatch/renderer.rb, line 24
        def to_html
            return <<~EOF
                <!doctype html>
                <html>
                <head>
                #{head}
                </head>
                <body>
                <div class="container">
                #{body}
                </div>
                <script>
                (function() {
                #{js}
                })()
                </script>
                </body>
                </html>
            EOF
        end

Protected Instance Methods

contents() click to toggle source
# File lib/docwatch/renderer.rb, line 51
def contents
    File.read(@file_path)
end
file_path() click to toggle source
# File lib/docwatch/renderer.rb, line 47
def file_path
    @file_path
end