Class: Deliruby::DeliciousBookmark
- Inherits:
-
Object
- Object
- Deliruby::DeliciousBookmark
- Defined in:
- lib/deliruby.rb
Overview
Abstract representation of a delicious bookmark item
Instance Attribute Summary collapse
-
#creator ⇒ Object
Who bookmarked it.
-
#published_on ⇒ Object
The date when the bookmark was made.
-
#tags ⇒ Object
The tags applied to it in this instance.
-
#title ⇒ Object
The title of this bookmark.
-
#url ⇒ Object
The bookmarked url.
Instance Method Summary collapse
-
#initialize(url, title = "", published_on = nil, creator = "", tags = []) ⇒ DeliciousBookmark
constructor
A new instance of DeliciousBookmark.
-
#to_hash ⇒ Object
convert this instance into a hash, based on this snippet.
Constructor Details
#initialize(url, title = "", published_on = nil, creator = "", tags = []) ⇒ DeliciousBookmark
Returns a new instance of DeliciousBookmark.
19 20 21 22 23 24 25 |
# File 'lib/deliruby.rb', line 19 def initialize(url, title="", published_on=nil, creator="", =[]) @url = url @tags = || [] @title = title || "" @published_on = published_on ? DateTime.strptime(published_on, "%a, %d %b %Y %H:%M:%S %Z") : nil @creator = creator || "" end |
Instance Attribute Details
#creator ⇒ Object
Who bookmarked it
17 18 19 |
# File 'lib/deliruby.rb', line 17 def creator @creator end |
#published_on ⇒ Object
The date when the bookmark was made
15 16 17 |
# File 'lib/deliruby.rb', line 15 def published_on @published_on end |
#tags ⇒ Object
The tags applied to it in this instance
11 12 13 |
# File 'lib/deliruby.rb', line 11 def @tags end |
#title ⇒ Object
The title of this bookmark
13 14 15 |
# File 'lib/deliruby.rb', line 13 def title @title end |
#url ⇒ Object
The bookmarked url
9 10 11 |
# File 'lib/deliruby.rb', line 9 def url @url end |
Instance Method Details
#to_hash ⇒ Object
convert this instance into a hash, based on this snippet
29 30 31 32 33 34 |
# File 'lib/deliruby.rb', line 29 def to_hash hsh = {} self.instance_variables.each do |var| hsh[var.gsub("@","")] = self.instance_variable_get(var) end end |