Sha256: 41a7863ed7302d7e02047fb63ca015aa3ad9db414eae2f340f2a68c449557cb3

Contents?: true

Size: 611 Bytes

Versions: 3

Compression:

Stored size: 611 Bytes

Contents

module Pinboard
  class Post < Struct.new(:href, :description, :tag, :time)
    def self.all(options={})
      client = Pinboard::Client.new(options)
      posts = client.class.get('/posts/all',
                :basic_auth => options)['posts']['post']
      posts.map { |p| Post.new(Util.symbolize_keys(p)) }
    end
    
    def initialize(attributes={})
      self.time = Util.parse_time(attributes.delete(:time))
      self.tag  = attributes.delete(:tag).split(" ")

      attributes.each do |attribute, value|
        send("#{attribute}=", value) if respond_to?("#{attribute}=")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pinboard-0.0.4 lib/pinboard/post.rb
pinboard-0.0.3 lib/pinboard/post.rb
pinboard-0.0.2 lib/pinboard/post.rb