Class: Geri::Page
- Inherits:
-
Object
- Object
- Geri::Page
- Defined in:
- app/models/geri/page.rb
Overview
Page encapsulates a site page and it’s metadata
Constant Summary collapse
- META_CAPTURE =
/\A---(.*)\n---\B/m
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#page_index ⇒ Object
readonly
Returns the value of attribute page_index.
Class Method Summary collapse
-
.find(path) ⇒ Page
Finds a page within the site and returns a new Page instance.
Instance Method Summary collapse
-
#initialize(path) ⇒ Page
constructor
A new instance of Page.
-
#metadata ⇒ Hash
Returns the metadata found in the metadata section of the page as a symbolized hash.
Constructor Details
#initialize(path) ⇒ Page
Returns a new instance of Page.
19 20 21 22 |
# File 'app/models/geri/page.rb', line 19 def initialize(path) @path = path @file = index_or_name end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
5 6 7 |
# File 'app/models/geri/page.rb', line 5 def file @file end |
#page_index ⇒ Object (readonly)
Returns the value of attribute page_index.
5 6 7 |
# File 'app/models/geri/page.rb', line 5 def page_index @page_index end |
Class Method Details
.find(path) ⇒ Page
Finds a page within the site and returns a new Page instance
13 14 15 16 |
# File 'app/models/geri/page.rb', line 13 def self.find(path) path = '/' unless path new(path) end |
Instance Method Details
#metadata ⇒ Hash
Returns the metadata found in the metadata section of the page as a symbolized hash
27 28 29 30 31 32 |
# File 'app/models/geri/page.rb', line 27 def unless @metadata && @metadata ||= YAML.load() end @metadata.symbolize_keys! end |