Class: Madness::Document
- Inherits:
-
Object
- Object
- Madness::Document
- Includes:
- ServerHelper
- Defined in:
- lib/madness/document.rb
Overview
Handle a single markdown document.
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#content ⇒ Object
Return the HTML for that document.
-
#content! ⇒ Object
Return the HTML for that document, force re-read.
-
#dir ⇒ Object
Return the path to the document directory.
-
#file ⇒ Object
Return the path to the actual markdown file.
-
#initialize(path) ⇒ Document
constructor
A new instance of Document.
-
#title ⇒ Object
Return the path to the document directory.
-
#type ⇒ Object
Return :readme, :file or :empty.
Methods included from ServerHelper
Constructor Details
#initialize(path) ⇒ Document
Returns a new instance of Document.
13 14 15 16 17 |
# File 'lib/madness/document.rb', line 13 def initialize(path) @path = path @base = path.empty? ? docroot : "#{docroot}/#{path}" @base.chomp! '/' end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
11 12 13 |
# File 'lib/madness/document.rb', line 11 def base @base end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/madness/document.rb', line 11 def path @path end |
Instance Method Details
#content ⇒ Object
Return the HTML for that document
44 45 46 |
# File 'lib/madness/document.rb', line 44 def content @content ||= content! end |
#content! ⇒ Object
Return the HTML for that document, force re-read.
49 50 51 |
# File 'lib/madness/document.rb', line 49 def content! type == :empty ? "<h1>#{title}</h1>" : markdown_to_html end |
#dir ⇒ Object
Return the path to the document directory
32 33 34 35 |
# File 'lib/madness/document.rb', line 32 def dir set_base_attributes unless @dir @dir end |
#file ⇒ Object
Return the path to the actual markdown file
26 27 28 29 |
# File 'lib/madness/document.rb', line 26 def file set_base_attributes unless @file @file end |
#title ⇒ Object
Return the path to the document directory
38 39 40 41 |
# File 'lib/madness/document.rb', line 38 def title set_base_attributes unless @title @title end |
#type ⇒ Object
Return :readme, :file or :empty
20 21 22 23 |
# File 'lib/madness/document.rb', line 20 def type set_base_attributes unless @type @type end |