Class: Page
Instance Method Summary collapse
-
#html ⇒ Object
Return the HTML rendering of this page.
-
#process ⇒ Object
Pull out metadata and markup the page.
- #to_s ⇒ Object
Methods inherited from Resource
#[], #delete, #initialize, #markup
Constructor Details
This class inherits a constructor from Resource
Instance Method Details
#html ⇒ Object
Return the HTML rendering of this page
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/den/page.rb', line 12 def html() _html = "<div id=\"page\">\n" # Wrap title in anchor if link is provided _html += "<h1 id=\"title\">#{@content[:title]}</h1>\n" # Add the rest of the necessary content _html += "<div id=\"body\">\n" + "#{@content[:body]}\n" + "</div>" + "</div>" _html end |
#process ⇒ Object
Pull out metadata and markup the page
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/den/page.rb', line 29 def process File.open(@file) do |f| page = markup(f.read) # Extract the url from the filename page[:id] = @file.split('/')[-1] # Store the processed info @content = page end end |
#to_s ⇒ Object
6 7 8 |
# File 'lib/den/page.rb', line 6 def to_s "Page: #{@content[:id]}" end |