Class: Markout::Document
- Inherits:
-
Object
- Object
- Markout::Document
- Defined in:
- lib/markout/document.rb
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#history ⇒ Object
readonly
Returns the value of attribute history.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path, options = { :history => true }) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(path, options = { :history => true }) ⇒ Document
Returns a new instance of Document.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/markout/document.rb', line 10 def initialize(path, ={ :history => true }) @path = File.(path) @base_path = Pathname.new( File.dirname(@path) ) @filename = File.basename(path) @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_path ⇒ Object (readonly)
Returns the value of attribute base_path.
8 9 10 |
# File 'lib/markout/document.rb', line 8 def base_path @base_path end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
8 9 10 |
# File 'lib/markout/document.rb', line 8 def content @content end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
8 9 10 |
# File 'lib/markout/document.rb', line 8 def filename @filename end |
#history ⇒ Object (readonly)
Returns the value of attribute history.
8 9 10 |
# File 'lib/markout/document.rb', line 8 def history @history end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/markout/document.rb', line 8 def path @path end |