Class: Octopress::Printable::PostLinkComparer
- Inherits:
-
Object
- Object
- Octopress::Printable::PostLinkComparer
- Defined in:
- lib/octopress-printable/tags.rb
Constant Summary collapse
- MATCHER =
/^(.+\/)*(\d+-\d+-\d+)-([^\s]*)(\s.*)?$/
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name) ⇒ PostLinkComparer
constructor
A new instance of PostLinkComparer.
Constructor Details
#initialize(name) ⇒ PostLinkComparer
Returns a new instance of PostLinkComparer.
21 22 23 24 25 26 27 |
# File 'lib/octopress-printable/tags.rb', line 21 def initialize(name) all, path, date, slug, text = *name.sub(/^\//, "").match(MATCHER) raise ArgumentError.new("'#{name}' does not contain valid date and/or title") unless all @slug = path ? path + slug : slug @date = Time.parse(date) @text = text end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
19 20 21 |
# File 'lib/octopress-printable/tags.rb', line 19 def date @date end |
#slug ⇒ Object
Returns the value of attribute slug.
19 20 21 |
# File 'lib/octopress-printable/tags.rb', line 19 def slug @slug end |
#text ⇒ Object
Returns the value of attribute text.
19 20 21 |
# File 'lib/octopress-printable/tags.rb', line 19 def text @text end |
Instance Method Details
#==(other) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/octopress-printable/tags.rb', line 29 def ==(other) slug == post_slug(other) # disabled the date check below (used in post_url.rb) # otherwise posts with a custom date front-matter will fail if it's different to the slug #&& date.year == other.date.year && #date.month == other.date.month && #date.day == other.date.day end |