Ruby Twitter Gem簡易リファレンス
Ruby Twitter Gemの日本語リファレンス(というかメモ)です。
インストール
gem install twitter でインストール。
ただし hpricot 0.5 とは相性が悪いため、hpricot 0.5を使っている人は
gem install hpricot --source http://code.whytheluckystiff.netで開発版snapshotを入れるとかで対処してください。
(0.6なら大丈夫かな?)
概要
使い方はこんな感じ(本家より抜粋)。
require 'twitter'
twit = Twitter::Base.new("mail", "pass")
twit.update('watching veronica mars')
puts "Public Timeline", "=" * 50
twit.timeline(:public).each do |s|
puts s.text, s.user.name
puts
end
puts '', "Friends Timeline", "=" * 50
twit.timeline(:friends).each do |s|
puts s.text, s.user.name
puts
end
あとtwitterというコマンドラインツールが付いてきます。
twitter post "releasing my new twitter gem"
とか。
リファレンス
rdefsは便利ですね。
yhara@meteor:~/rubygems/twitter-0.1.0/lib/twitter % for r in *.rb; do echo ----------------$r----------------; rdefs.rb $r; done
class Base
- Base.new(email, password)
- (String, String) -> Twitter::Base
- timeline(which=
- friends):Array of Twitter::Status
- friends
- Array of Twitter::User
- friends_for(id)
- id or username -> Array of Twitter::User
- followers
- Array of Twitter::User (自分のfollowers)
- direct_messages(since=nil)
- Array of Twitter::DirectMessage? (0.1.0ではsinceは無視される?)
- post(status)
- String (-> Twitter::Status)
- update(status)
- String (-> Twitter::Status) postのalias
class DirectMessage?
- id / String
- text / String
- sender_id / String
- recipient_id / String
- created_at / String
- sender_screen_name / String
- recipient_screen_name / String
class Status
- created_at / String
- id / String
- text / String
- user / User
class User
- id / String
- name / String
- screen_name / String
- status / Status
- location / String
- description / String
- url / String
- profile_image_url / String
class Command
コマンドラインツール(bin/twitter)のためのクラス。
def Command.process!
def Command.commands
def Command.post
def Command.timeline
def Command.friends
def Command.friend
def Command.followers
def Command.follower
def Command.featured
def Command.important
Keyword(s):
References: