Class: PageViewer::Page
- Inherits:
-
Object
- Object
- PageViewer::Page
- Defined in:
- lib/page_viewer/page.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #contents ⇒ Object
-
#initialize(root, name) ⇒ Page
constructor
A new instance of Page.
- #parse_page ⇒ Object
Constructor Details
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/page_viewer/page.rb', line 4 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
4 5 6 |
# File 'lib/page_viewer/page.rb', line 4 def headers @headers end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/page_viewer/page.rb', line 4 def name @name end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
4 5 6 |
# File 'lib/page_viewer/page.rb', line 4 def root @root end |
Class Method Details
Instance Method Details
#contents ⇒ Object
26 27 28 29 30 |
# File 'lib/page_viewer/page.rb', line 26 def contents @contents ||= File.open(self.class.path(root, name), 'r:utf-8') do |file| file.read end end |
#parse_page ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/page_viewer/page.rb', line 16 def parse_page if contents =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)(.*)/m @headers = YAML.load($1) @body = $3 else @headers = {} @body = contents end end |