Class: HatenaBookmarkClientForRuby::Entry
- Inherits:
-
Object
- Object
- HatenaBookmarkClientForRuby::Entry
- Defined in:
- lib/hatena_bookmark_client_for_ruby.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #get ⇒ Object
- #get_withou_relations ⇒ Object
-
#initialize(url) ⇒ Entry
constructor
A new instance of Entry.
Constructor Details
#initialize(url) ⇒ Entry
Returns a new instance of Entry.
30 31 32 |
# File 'lib/hatena_bookmark_client_for_ruby.rb', line 30 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
28 29 30 |
# File 'lib/hatena_bookmark_client_for_ruby.rb', line 28 def url @url end |
Instance Method Details
#get ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/hatena_bookmark_client_for_ruby.rb', line 34 def get() encoded = URI.encode(url) uri = URI.parse("http://b.hatena.ne.jp/entry/json/#{url}") http = Net::HTTP.new(uri.host, uri.port) headers = { "content-Type" => "application/json" } http.get(uri.path, headers) end |
#get_withou_relations ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/hatena_bookmark_client_for_ruby.rb', line 42 def get_withou_relations() encoded = URI.encode(url) uri = URI.parse("http://b.hatena.ne.jp/entry/jsonlite/#{url}") http = Net::HTTP.new(uri.host, uri.port) headers = { "content-Type" => "application/json" } http.get(uri.path, headers) end |