Class: Page
- Inherits:
-
Object
- Object
- Page
- Defined in:
- lib/mook/page.rb
Constant Summary collapse
- METADATA =
%w{ title template order }
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#markdown ⇒ Object
readonly
Returns the value of attribute markdown.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#output ⇒ Object
Returns the value of attribute output.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#toc ⇒ Object
Returns the value of attribute toc.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, title, template, order, markdown) ⇒ Page
constructor
A new instance of Page.
- #url ⇒ Object
Constructor Details
#initialize(name, title, template, order, markdown) ⇒ Page
Returns a new instance of Page.
22 23 24 25 26 27 28 |
# File 'lib/mook/page.rb', line 22 def initialize(name, title, template, order, markdown) @name = name.gsub(/\.[^\.]+$/, "") @title = title @template = template @order = order @markdown = markdown end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
20 21 22 |
# File 'lib/mook/page.rb', line 20 def content @content end |
#markdown ⇒ Object (readonly)
Returns the value of attribute markdown.
19 20 21 |
# File 'lib/mook/page.rb', line 19 def markdown @markdown end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
19 20 21 |
# File 'lib/mook/page.rb', line 19 def name @name end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
19 20 21 |
# File 'lib/mook/page.rb', line 19 def order @order end |
#output ⇒ Object
Returns the value of attribute output.
20 21 22 |
# File 'lib/mook/page.rb', line 20 def output @output end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
19 20 21 |
# File 'lib/mook/page.rb', line 19 def template @template end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
19 20 21 |
# File 'lib/mook/page.rb', line 19 def title @title end |
#toc ⇒ Object
Returns the value of attribute toc.
20 21 22 |
# File 'lib/mook/page.rb', line 20 def toc @toc end |
Class Method Details
.load(filename) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mook/page.rb', line 4 def self.load(filename) lines = File.read(filename) m, markdown = lines.split("* * *\n", 2) = Hash[*m.split("\n").map { |s| s.split(": ", 2) }.map { |k, v| [k.downcase, v] }.flatten] raise "#{filename} has no title" unless ["title"] raise "#{filename} has no template" unless ["template"] order = (["order"] || 1000).to_i Page.new(File.basename(filename), ["title"], ["template"], order, markdown.strip) end |
Instance Method Details
#url ⇒ Object
30 31 32 |
# File 'lib/mook/page.rb', line 30 def url "#{@name}.html" end |