Permalink
Browse files

Move loose comparison to own method

  • Loading branch information...
1 parent 87f6f8c commit 9d751fa0c51497285a694d6d10d45ecc837be920 @dhilgarth committed Mar 4, 2013
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/jekyll/tags/post_url.rb
View
11 lib/jekyll/tags/post_url.rb
@@ -10,6 +10,15 @@ def initialize(name)
@slug = slug
@date = Time.parse(date)
end
+
+ def looseCompare(post)
+ return false unless post.slug == self.slug
+ return false unless post.date.year == self.date.year
+ return false unless post.date.month == self.date.month
+ return false unless post.date.day == self.date.day
+ return true
+ end
+
end
class PostUrl < Liquid::Tag
@@ -23,7 +32,7 @@ def render(context)
site = context.registers[:site]
site.posts.each do |p|
- if p.slug == @post.slug and p.date.year == @post.date.year and p.date.month == @post.date.month and p.date.day == @post.date.day
+ if @post.looseCompare(p)
return p.url
end
end

0 comments on commit 9d751fa

Please sign in to comment.