Sha256: 762c3d3ceb2008676bd66819a3cb0e9166339035c87ef5adf50083477d58d1fa
Contents?: true
Size: 949 Bytes
Versions: 2
Compression:
Stored size: 949 Bytes
Contents
module Pinboard class Post < Struct.new(:href, :description, :extended, :tag, :time, :replace, :shared, :toread) 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 def to_json(*args) { href: href, description: description, extended: extended, tag: tag, time: time, replace: replace, shared: shared, toread: toread }.to_json(*args) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pinboard-0.1.1 | lib/pinboard/post.rb |
pinboard-0.1.0 | lib/pinboard/post.rb |