Method: Jekyll::Tags::PostComparer#initialize

Defined in:
lib/ngage/jekyll/tags/post_url.rb

#initialize(name) ⇒ PostComparer

Returns a new instance of PostComparer.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ngage/jekyll/tags/post_url.rb', line 10

def initialize(name)
  @name = name

  all, @path, @date, @slug = *name.sub(%r!^/!, "").match(MATCHER)
  unless all
    raise Jekyll::Errors::InvalidPostNameError,
          "'#{name}' does not contain valid date and/or title."
  end

  escaped_slug = Regexp.escape(slug)
  @name_regex = %r!^_posts/#{path}#{date}-#{escaped_slug}\.[^.]+|
    ^#{path}_posts/?#{date}-#{escaped_slug}\.[^.]+!x
end