Method: Brief::Document#initialize

Defined in:
lib/brief/document.rb

#initialize(path, options = {}) ⇒ Document

Returns a new instance of Document.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/brief/document.rb', line 25

def initialize(path, options = {})
  if path.respond_to?(:key?) && options.empty?
    @frontmatter = path.to_mash
  else
    @path = Pathname(path)
  end

  @options = options.to_mash

  if @path && self.path.exist?
    @raw_content = self.path.read
    load_frontmatter
  elsif options[:contents]
    @raw_content = options[:contents]
  end
end