Class: HatenaBookmarkClientForRuby::Entry

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#urlObject

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

#getObject



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_relationsObject



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