Declaration
class UserSummary
Response = Struct.new(:id, :uri, :title, :count, :favorite, :follower)
def initialize(proxy = nil) # UserSummary.new(str) -> summary
def reset() # summary.reset() -> summary
def get(id) # summary.get(id) -> response
def each(id) # summary.each(str/arr) { |response| block } -> summary
end
Overview
Bookmark::UserSummary は,指定されたユーザの情報を取得するためのクラスです. get() でユーザ ID を指定すると,対応するユーザのブックマークページに関する情報を返します.
each() メソッドは,get() と同様に指定されたユーザ ID に対応する情報を取得し, その結果をブロックへ渡します.each() には配列で複数のユーザ ID を指定することもできます.
Response 構造体の各メンバ変数は以下の通りです.
- id ..... ユーザ ID (String)
- uri ..... ブックマークページの URI (String)
- title ..... タイトル (String)
- count ..... 総ブックマーク数 (Integer)
- favorite ..... お気に入り数 (Integer)
- follower ..... お気にいられ数 (Integer)
Example
#!/usr/bin/ruby -Ku
require 'hatena'
list = ["tt_clown", "jkondo", "naoya"]
Hatena::Bookmark::UserSummary.new.each(list) { |entry|
puts("#{entry.id}")
puts("----------")
puts("URI : #{entry.uri}")
puts("Title : #{entry.title}")
puts("Count : #{entry.count}")
puts("Favorite : #{entry.favorite}")
puts("Follower : #{entry.follower}")
puts
}
Result tt_clown ---------- URI : http://b.hatena.ne.jp/tt_clown/ Title : Bookmark life like a clown Count : 2998 Favorite : 10 Follower : 8 jkondo ---------- URI : http://b.hatena.ne.jp/jkondo/ Title : jkondoのブックマーク Count : 1908 Favorite : 6 Follower : 998 naoya ---------- URI : http://b.hatena.ne.jp/naoya/ Title : naoyaのブックマーク Count : 6370 Favorite : 109 Follower : 1605