Class: Ldclip

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclip/version.rb,
lib/ldclip.rb

Overview

:nodoc:

Defined Under Namespace

Modules: VERSION

Constant Summary collapse

LIVEDOOR_CLIP_HOST =
'api.clip.livedoor.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, apikey) ⇒ Ldclip

user,apikey get apikey at this url clip.livedoor.com/config/api



19
20
21
22
# File 'lib/ldclip.rb', line 19

def initialize(user, apikey)
  @user = user
  @apikey = apikey
end

Instance Attribute Details

#apikeyObject (readonly)

Returns the value of attribute apikey.



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

def apikey
  @apikey
end

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#add(url, description, options = {}) ⇒ Object

options extended # as comment for bookmark tags dt (date) replace shared rate r18



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/ldclip.rb', line 68

def add(url, description, options = {})
  params = []
  params << "url=#{url}"
  params << "description=#{CGI.escape(NKF.nkf('-w',description))}"  
  
  options.each do |t,e|
     params << "#{t.to_s}=#{CGI.escape(NKF.nkf('-w',e.to_s))}"
  end 

  connect("posts/add?#{params.join('&')}")
end

#all(options = {}) ⇒ Object

options tag



53
54
55
56
57
# File 'lib/ldclip.rb', line 53

def all(options = {})
  params = ''
  params += "tag=#{CGI.escape(NKF.nkf('-w',options[:tag]))}"  if options[:tag]
  connect("posts/all?#{params}")
end

#delete(url) ⇒ Object



80
81
82
83
84
# File 'lib/ldclip.rb', line 80

def delete(url)
  params = "url=#{url}"  

  connect("posts/delete?#{params}")
end

#get(options = {}) ⇒ Object

options tag dt (date) url



33
34
35
36
37
38
39
# File 'lib/ldclip.rb', line 33

def get(options = {})
  params = []
  params << "tag=#{CGI.escape(NKF.nkf('-w',options[:tag]))}"  if options[:tag]
  params << "dt=#{options[:dt]}"    if options[:dt]
  params << "url=#{options[:url]}"  if options[:url] 
  connect("posts/get?#{params.join('&')}")
end

#recent(options = {}) ⇒ Object

options tag count (default = 15,max = 100)



44
45
46
47
48
49
# File 'lib/ldclip.rb', line 44

def recent(options = {})
  params = []
  params << "tag=#{CGI.escape(NKF.nkf('-w',options[:tag]))}"  if options[:tag]
  params << "count=#{options[:count]}"  if options[:count]
  connect("posts/recent?#{params.join('&')}")
end

#updateObject

return last update date



25
26
27
# File 'lib/ldclip.rb', line 25

def update
  connect('posts/update')
end