Class: Hatena::Bookmark
- Inherits:
-
Object
- Object
- Hatena::Bookmark
- Defined in:
- lib/hatena-bookmark.rb
Instance Method Summary collapse
-
#create(params) ⇒ Object
PostURI hatebu.create(:url => “www.exapmle.com/”, :comment => “test”).
-
#delete_edit(params, options = {}) ⇒ Object
DELETE /atom/edit/XXXX.
-
#feed ⇒ Object
FeedURI.
-
#get_edit(options) ⇒ Object
GET /atom/edit/XXXX.
-
#initialize(params) ⇒ Bookmark
constructor
Hatena::Bookmark.new( :consumer_key => “”, :consumer_secret => “”, :request_token => “”, :request_secret => “” ).
-
#ok? ⇒ Boolean
# HTTP/1.1 201 hatebu.ok? #=> true.
-
#ping ⇒ Object
Root Atom Endpoint.
-
#put_edit(params) ⇒ Object
PUT /atom/edit/XXXX.
Constructor Details
#initialize(params) ⇒ Bookmark
Hatena::Bookmark.new(
:consumer_key => "",
:consumer_secret => "",
:request_token => "",
:request_secret => ""
)
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/hatena-bookmark.rb', line 13 def initialize(params) consumer = OAuth::Consumer.new( params[:consumer_key], params[:consumer_secret] ) @access_token = OAuth::AccessToken.new( consumer, params[:request_token], params[:request_secret] ) end |
Instance Method Details
#create(params) ⇒ Object
PostURI
hatebu.create(:url => “www.exapmle.com/”, :comment => “test”)
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/hatena-bookmark.rb', line 33 def create(params) xml =<<XML <entry xmlns="http://purl.org/atom/ns#"> <title>#{params[:title]}</title> <link rel="related" type="text/html" href="#{params[:url]}" /> <summary type="text/plain">#{params[:comment]}</summary> </entry> XML post('/post', xml) end |
#delete_edit(params, options = {}) ⇒ Object
DELETE /atom/edit/XXXX
64 65 66 |
# File 'lib/hatena-bookmark.rb', line 64 def delete_edit(params,={}) delete("/edit/#{params[:eid]}",) end |
#feed ⇒ Object
FeedURI
69 70 71 |
# File 'lib/hatena-bookmark.rb', line 69 def feed get('/feed') end |
#get_edit(options) ⇒ Object
GET /atom/edit/XXXX
47 48 49 |
# File 'lib/hatena-bookmark.rb', line 47 def get_edit() get("/edit/#{[:eid]}",) end |
#ok? ⇒ Boolean
# HTTP/1.1 201 hatebu.ok? #=> true
75 76 77 |
# File 'lib/hatena-bookmark.rb', line 75 def ok? @response.is_a? Net::HTTPOK end |
#ping ⇒ Object
Root Atom Endpoint
27 28 29 |
# File 'lib/hatena-bookmark.rb', line 27 def ping get('') end |
#put_edit(params) ⇒ Object
PUT /atom/edit/XXXX
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/hatena-bookmark.rb', line 52 def put_edit(params) xml =<<XML <entry xmlns="http://purl.org/atom/ns#"> <title>#{params[:title]}</title> <summary type="text/plain">#{params[:comment]}</summary> </entry> XML put("/edit/#{params[:eid]}",xml) end |