Sha256: aecb5c6ab8241e9da2e9bb2a2a97e84de9f8b6c9b65c9788df3ae082296f063e

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 Bytes

Contents

module Twog
  class Post
    def initialize(post)
      @post = post
    end

    def link
      @post.link.respond_to?('href') ? @post.link.href : @post.link
    end

    def date
      @post.respond_to?('updated') ? @post.updated.content : @post.pubDate
    end
    
    def title
      @post.title.respond_to?('content') ? @post.title.content : @post.title
    end
    
    def <=>(other_post)
      this_time = Time.parse(self.date.to_s)
      other_time = Time.parse(other_post.date.to_s)
      if this_time < other_time
        -1
      elsif this_time > other_time
        1
      else
        0
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twog-0.3.1 lib/twog/post.rb