Class: Jekyll::Tags::PostComparer

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/tags/post_url.rb

Constant Summary collapse

MATCHER =
/^(.+\/)*(\d+-\d+-\d+)-(.*)$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ PostComparer

Returns a new instance of PostComparer.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
# File 'lib/jekyll/tags/post_url.rb', line 8

def initialize(name)
  all, path, date, slug = *name.sub(/^\//, "").match(MATCHER)
  raise ArgumentError.new("'#{name}' does not contain valid date and/or title.") unless all
  @slug = path ? path + slug : slug
  @date = Utils.parse_date(date, "'#{name}' does not contain valid date.")
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



6
7
8
# File 'lib/jekyll/tags/post_url.rb', line 6

def date
  @date
end

#slugObject

Returns the value of attribute slug.



6
7
8
# File 'lib/jekyll/tags/post_url.rb', line 6

def slug
  @slug
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
18
19
20
# File 'lib/jekyll/tags/post_url.rb', line 15

def ==(other)
  slug == post_slug(other) &&
    date.year  == other.date.year &&
    date.month == other.date.month &&
    date.day   == other.date.day
end