Class: Post
Constant Summary collapse
- @@glob =
"*.{md,mkd,markdown}"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file_path) ⇒ Post
constructor
A new instance of Post.
- #url ⇒ Object
Methods inherited from MdContent
Methods inherited from Content
#account, #account?, #child, #content, #datas, #dir, #gravatar, #gravatar?, #method_missing, #raw_content, #url=
Methods included from Configuration
#config, config, #defaultLinks, defaultLinks, links_file_path, read_config, read_configuration, read_default_links, valid_location?
Constructor Details
#initialize(file_path) ⇒ Post
Returns a new instance of Post.
7 8 9 10 11 12 13 |
# File 'lib/post.rb', line 7 def initialize file_path super file_path base_path = File.join(Configuration.config['path'], '_posts') + '/' @cats = @cats.gsub(base_path, '') if !@cats.nil? @cats.chomp!('/') end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Content
Class Method Details
Instance Method Details
#url ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/post.rb', line 15 def url generate_url = { "year" => @date.strftime("%Y"), "month" => @date.strftime("%m"), "day" => @date.strftime("%d"), "title" => CGI.escape(@slug) }.inject(":year/:month/:day/:title.html") { |result, token| result.gsub(/:#{Regexp.escape token.first}/, token.last) }.gsub(/\/\//, "/") generate_url = "#{@cats}/#{generate_url}" if @cats != '' generate_url end |