Class: Pinboard::Post
- Inherits:
-
Struct
- Object
- Struct
- Pinboard::Post
- Defined in:
- lib/pinboard/post.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#extended ⇒ Object
Returns the value of attribute extended.
-
#href ⇒ Object
Returns the value of attribute href.
-
#replace ⇒ Object
Returns the value of attribute replace.
-
#shared ⇒ Object
Returns the value of attribute shared.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#time ⇒ Object
Returns the value of attribute time.
-
#toread ⇒ Object
Returns the value of attribute toread.
Class Method Summary collapse
Instance Method Summary collapse
-
#api_hash(replace = nil) ⇒ Hash
Creates hash for API (e.g. pass it to ‘/posts/add’).
-
#initialize(attributes = {}) ⇒ Post
constructor
A new instance of Post.
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Post
Returns a new instance of Post.
10 11 12 13 14 15 16 17 |
# File 'lib/pinboard/post.rb', line 10 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 |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description
2 3 4 |
# File 'lib/pinboard/post.rb', line 2 def description @description end |
#extended ⇒ Object
Returns the value of attribute extended
2 3 4 |
# File 'lib/pinboard/post.rb', line 2 def extended @extended end |
#href ⇒ Object
Returns the value of attribute href
2 3 4 |
# File 'lib/pinboard/post.rb', line 2 def href @href end |
#replace ⇒ Object
Returns the value of attribute replace
2 3 4 |
# File 'lib/pinboard/post.rb', line 2 def replace @replace end |
#shared ⇒ Object
Returns the value of attribute shared
2 3 4 |
# File 'lib/pinboard/post.rb', line 2 def shared @shared end |
#tag ⇒ Object
Returns the value of attribute tag
2 3 4 |
# File 'lib/pinboard/post.rb', line 2 def tag @tag end |
#time ⇒ Object
Returns the value of attribute time
2 3 4 |
# File 'lib/pinboard/post.rb', line 2 def time @time end |
#toread ⇒ Object
Returns the value of attribute toread
2 3 4 |
# File 'lib/pinboard/post.rb', line 2 def toread @toread end |
Class Method Details
Instance Method Details
#api_hash(replace = nil) ⇒ Hash
Creates hash for API (e.g. pass it to ‘/posts/add’)
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pinboard/post.rb', line 36 def api_hash(replace = nil) self.replace = replace unless replace.nil? { url: href, description: description, extended: extended, tags: tag.join(" "), replace: replace, shared: shared, toread: toread }.select { |key, value| ! value.nil? } end |
#to_json(*args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pinboard/post.rb', line 19 def to_json(*args) { href: href, description: description, extended: extended, tag: tag, time: time, replace: replace, shared: shared, toread: toread }.to_json(*args) end |