Class: Dimples::Post
Overview
A class that models a single site post.
Constant Summary collapse
- FILENAME_DATE =
/(\d{4})-(\d{2})-(\d{2})-(.+)/
Constants included from Frontable
Frontable::SKIPPED_METADATA_KEYS
Instance Attribute Summary collapse
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#date ⇒ Object
Returns the value of attribute date.
-
#day ⇒ Object
Returns the value of attribute day.
-
#month ⇒ Object
Returns the value of attribute month.
-
#next_post ⇒ Object
Returns the value of attribute next_post.
-
#previous_post ⇒ Object
Returns the value of attribute previous_post.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#year ⇒ Object
Returns the value of attribute year.
Attributes inherited from Page
#contents, #extension, #filename, #layout, #output_directory, #path, #title
Attributes included from Renderable
Instance Method Summary collapse
-
#initialize(site, path) ⇒ Post
constructor
A new instance of Post.
- #inspect ⇒ Object
Methods inherited from Page
Methods included from Renderable
Methods included from Frontable
Constructor Details
#initialize(site, path) ⇒ Post
Returns a new instance of Post.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dimples/post.rb', line 18 def initialize(site, path) super(site, path) parts = File.basename(path, File.extname(path)).match(FILENAME_DATE) @filename = 'index' @slug = parts[4] @layout = @site.config['layouts']['post'] self.date = Time.mktime(parts[1], parts[2], parts[3]) @output_directory = File.join( @date.strftime(@site.output_paths[:posts]), @slug.to_s ) end |
Instance Attribute Details
#categories ⇒ Object
Returns the value of attribute categories.
8 9 10 |
# File 'lib/dimples/post.rb', line 8 def categories @categories end |
#date ⇒ Object
Returns the value of attribute date.
14 15 16 |
# File 'lib/dimples/post.rb', line 14 def date @date end |
#day ⇒ Object
Returns the value of attribute day.
11 12 13 |
# File 'lib/dimples/post.rb', line 11 def day @day end |
#month ⇒ Object
Returns the value of attribute month.
10 11 12 |
# File 'lib/dimples/post.rb', line 10 def month @month end |
#next_post ⇒ Object
Returns the value of attribute next_post.
13 14 15 |
# File 'lib/dimples/post.rb', line 13 def next_post @next_post end |
#previous_post ⇒ Object
Returns the value of attribute previous_post.
12 13 14 |
# File 'lib/dimples/post.rb', line 12 def previous_post @previous_post end |
#slug ⇒ Object
Returns the value of attribute slug.
6 7 8 |
# File 'lib/dimples/post.rb', line 6 def slug @slug end |
#summary ⇒ Object
Returns the value of attribute summary.
7 8 9 |
# File 'lib/dimples/post.rb', line 7 def summary @summary end |
#year ⇒ Object
Returns the value of attribute year.
9 10 11 |
# File 'lib/dimples/post.rb', line 9 def year @year end |
Instance Method Details
#inspect ⇒ Object
43 44 45 |
# File 'lib/dimples/post.rb', line 43 def inspect "#<Dimples::Post @slug=#{@slug} @output_path=#{output_path}>" end |