From 4a3a404a5cb2a8d5be83e28cec5c539928fa30f4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 6 Jan 2017 23:18:24 -0500 Subject: aaaah --- lib/page.rb | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'lib/page.rb') 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 + # def page_categories => String | Enumerable # - # def _published => DateTime | nil - # def _updated => DateTime | nil - # def _years => Enumerable + # def page_published => DateTime | nil + # def page_updated => DateTime | nil + # def page_years => Enumerable - def tags # => Enumerable - if @tags.nil? - raw = _tags + def atom_categories # => Enumerable + 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) -- cgit v1.2.3-54-g00ecf