Sha256: c31c8256af628db2a30b788112a4aafcc69ed6e3085666a5c7c57f636c5891a5

Contents?: true

Size: 674 Bytes

Versions: 1

Compression:

Stored size: 674 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'nokogiri'
require 'bluecloth'

module Genit

  # Open an html file in various format.
  class HtmlDocument
  
    # Public: Open a html document.
    #
    # file - Full path String filename
    #
    # Returns a Nokogiri::HTML document
    def self.open file
      Nokogiri::HTML(File.open(file))
    end
    
    # Public: Open a html or markdown file as a string.
    #
    # file - Full path String name of a html or markdown file.
    #
    # Returns a String
    def self.open_as_string file
      string = IO.read file
      string = BlueCloth.new(string).to_html if file.end_with? '.markdown'
      string
    end
    
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
genit-0.1 lib/genit/html_document.rb