Class: Dimples::Entries::Post
Overview
A page from a site with a date.
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#contents, #metadata, #path, #rendered_contents
Instance Method Summary collapse
-
#initialize(site:, path:) ⇒ Post
constructor
A new instance of Post.
- #output_directory ⇒ Object
- #slug ⇒ Object
- #template ⇒ Object
Methods inherited from Base
#method_missing, #parse_metadata, #render, #respond_to_missing?, #write
Constructor Details
#initialize(site:, path:) ⇒ Post
Returns a new instance of Post.
7 8 9 |
# File 'lib/dimples/entries/post.rb', line 7 def initialize(site:, path:) super(site: site, source: Pathname.new(path)) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Dimples::Entries::Base
Instance Method Details
#output_directory ⇒ Object
11 12 13 14 15 16 |
# File 'lib/dimples/entries/post.rb', line 11 def output_directory @output_directory ||= File.dirname(@path).gsub( @site.config.source_paths[:posts], @site.config.build_paths[:posts] ).concat("/#{slug}/") end |
#slug ⇒ Object
18 19 20 |
# File 'lib/dimples/entries/post.rb', line 18 def slug File.basename(@path, '.markdown') end |
#template ⇒ Object
22 23 24 |
# File 'lib/dimples/entries/post.rb', line 22 def template @template ||= Tilt::RedcarpetTemplate.new { @contents } end |