Class: Deliruby::DeliciousBookmark

Inherits:
Object
  • Object
show all
Defined in:
lib/deliruby.rb

Overview

Abstract representation of a delicious bookmark item

Instance Attribute Summary collapse

Instance Method Summary collapse

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="", tags=[])
    @url = url 
    @tags = 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

#creatorObject

Who bookmarked it



17
18
19
# File 'lib/deliruby.rb', line 17

def creator
  @creator
end

#published_onObject

The date when the bookmark was made



15
16
17
# File 'lib/deliruby.rb', line 15

def published_on
  @published_on
end

#tagsObject

The tags applied to it in this instance



11
12
13
# File 'lib/deliruby.rb', line 11

def tags
  @tags
end

#titleObject

The title of this bookmark



13
14
15
# File 'lib/deliruby.rb', line 13

def title
  @title
end

#urlObject

The bookmarked url



9
10
11
# File 'lib/deliruby.rb', line 9

def url
  @url
end

Instance Method Details

#to_hashObject

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