Class: Sawsge::Post
Overview
A blogpost style HTML page
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
Attributes inherited from Page
Attributes inherited from Resource
Instance Method Summary collapse
-
#initialize(path) ⇒ Post
constructor
A new instance of Post.
Methods inherited from Page
Methods inherited from Resource
Constructor Details
#initialize(path) ⇒ Post
Returns a new instance of Post.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/post.rb', line 8 def initialize(path) super(path) # There's got to be a more idiomatic way to do this! The # current implementation is disguisting. # Also doesn't work if POSTS_DIRNAME is more than 2 # directories parts = Pathname.new(@path).each_filename.to_a[1..] parts.delete(POSTS_DIRNAME) @date = "#{parts[0]}-#{parts[1]}-#{parts[2]}" @body.css('h1').first.add_next_sibling "<date>#{@date}</date>" # Look what's in <summary></summary> @summary = @document.css('summary').first.content end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
6 7 8 |
# File 'lib/post.rb', line 6 def date @date end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
6 7 8 |
# File 'lib/post.rb', line 6 def summary @summary end |