Class: Geri::Page

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'app/models/geri/page.rb', line 5

def file
  @file
end

#page_indexObject (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

Parameters:

  • path (string|NilClass)

    the url path for which to look for the page

Returns:

  • (Page)

    a page object



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

#metadataHash

Returns the metadata found in the metadata section of the page as a symbolized hash

Returns:

  • (Hash)

    the page metadata



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