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.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#content ⇒ Object
Return the HTML for that document.
-
#content! ⇒ Object
Return the HTML for that document, force re-read.
-
#initialize(path) ⇒ Document
constructor
A new instance of Document.
Methods included from ServerHelper
Constructor Details
#initialize(path) ⇒ Document
Returns a new instance of Document.
13 14 15 16 17 18 |
# File 'lib/madness/document.rb', line 13 def initialize(path) @path = path @base = path.empty? ? docroot : "#{docroot}/#{path}" @base.chomp! '/' set_base_attributes 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 |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
11 12 13 |
# File 'lib/madness/document.rb', line 11 def dir @dir end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
11 12 13 |
# File 'lib/madness/document.rb', line 11 def file @file end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/madness/document.rb', line 11 def path @path end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/madness/document.rb', line 11 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/madness/document.rb', line 11 def type @type end |
Instance Method Details
#content ⇒ Object
Return the HTML for that document
21 22 23 |
# File 'lib/madness/document.rb', line 21 def content @content ||= content! end |
#content! ⇒ Object
Return the HTML for that document, force re-read.
26 27 28 |
# File 'lib/madness/document.rb', line 26 def content! [:empty, :missing].include?(type) ? "<h1>#{title}</h1>" : markdown_to_html end |