diff options
Diffstat (limited to 'lib/page.rb')
-rw-r--r-- | lib/page.rb | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/page.rb b/lib/page.rb index d0b18ef..64bbaea 100644 --- a/lib/page.rb +++ b/lib/page.rb @@ -1,7 +1,7 @@ # coding: utf-8 require 'set' -require 'tag' +require 'category' class Page # Page is an abstract class. @@ -9,54 +9,54 @@ class Page # Implementors must implement several methods: # # def url => URI - # def title => String - # def author => Person - # def content => html | nil - # def rights => html | nil + # def atom_title => String + # def atom_author => Person + # def atom_content => html | nil + # def atom_rights => html | nil # - # def _tags => String | Enumerable<String> + # def page_categories => String | Enumerable<String> # - # def _published => DateTime | nil - # def _updated => DateTime | nil - # def _years => Enumerable<Fixnum> + # def page_published => DateTime | nil + # def page_updated => DateTime | nil + # def page_years => Enumerable<Fixnum> - def tags # => Enumerable<Tag> - if @tags.nil? - raw = _tags + def atom_categories # => Enumerable<Category> + if @categories.nil? + raw = page_categories if raw.is_a?(String) raw = raw.split end - @tags = raw.map{|tag|Tag.new(tag)} + @categories = raw.map{|abbr|Category.new(abbr)} end - @tags + @categories end - def published # => DateTime | nil + def atom_published # => DateTime | nil if @published.nil? - unless _published.nil? - @published = _published + unless page_published.nil? + @published = page_published else - unless _updated.nil? - @published = _updated + unless page_updated.nil? + @published = page_updated end end # sanity check - unless _published.nil? or _updated.nil? - if _updated < _published - @published = _updated + unless page_published.nil? or page_updated.nil? + if page_updated < page_published + @published = page_updated end end end @published end - def updated # => DateTime | nil + def atom_updated # => DateTime | nil if @updated.nil? - unless _updated.nil? - @updated = _updated + unless page_updated.nil? + @updated = page_updated else - unless _published.nil? - @updated = _published + unless page_published.nil? + @updated = page_published end end end @@ -71,7 +71,7 @@ class Page first = published.year last = updated.year - years = _years + years = page_years years.add(first) years.add(last) |