Class: Markout::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/markout/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = { :history => true }) ⇒ Document

Returns a new instance of Document.

Raises:



10
11
12
13
14
15
16
17
18
19
# File 'lib/markout/document.rb', line 10

def initialize(path, options={ :history => true })
  @path      = File.expand_path(path)
  @base_path = Pathname.new( File.dirname(@path) )
  @filename  = File.basename(path)
  @options   = options
  raise FileNotFound, "File #{@path} not found" unless File.exist?(@path)
  raise FileNotSupported, "File #{@path} is not plain text" unless MIME::Types.type_for(@path).any? { |type| type.media_type == 'text' }
  @content   = File.read(path)
  @history   = Markout::History.new(self, :git_dir => @options[:git_dir]) if @options[:history]
end

Instance Attribute Details

#base_pathObject (readonly)

Returns the value of attribute base_path.



8
9
10
# File 'lib/markout/document.rb', line 8

def base_path
  @base_path
end

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/markout/document.rb', line 8

def content
  @content
end

#filenameObject (readonly)

Returns the value of attribute filename.



8
9
10
# File 'lib/markout/document.rb', line 8

def filename
  @filename
end

#historyObject (readonly)

Returns the value of attribute history.



8
9
10
# File 'lib/markout/document.rb', line 8

def history
  @history
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/markout/document.rb', line 8

def path
  @path
end