Module: Atig::Command::Info
- Defined in:
- lib/atig/command/info.rb
Class Method Summary collapse
- .find_status(db, tid_or_screen_name) ⇒ Object
- .status(db, api, id, &f) ⇒ Object
- .user(db, api, name, &f) ⇒ Object
Class Method Details
.find_status(db, tid_or_screen_name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/atig/command/info.rb', line 31 def find_status(db, tid_or_screen_name) find = lambda do|x| xs = db.statuses.find_by_screen_name(x, :limit=>1) unless xs.empty? then xs.first else nil end end (db.statuses.find_by_tid(tid_or_screen_name) || db.statuses.find_by_sid(tid_or_screen_name) || find.call(tid_or_screen_name) || find.call(tid_or_screen_name.sub(/\A@/,''))) end |
.status(db, api, id, &f) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/atig/command/info.rb', line 17 def status(db, api, id, &f) if status = db.statuses.find_by_status_id(id) then f.call status else api.delay(0) do|t| status = t.get "statuses/show/#{id}" db.statuses.transaction do|d| d.add :status => status, :user => status.user, :source => :thread f.call d.find_by_status_id(id) end end end end |
.user(db, api, name, &f) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/atig/command/info.rb', line 6 def user(db, api, name, &f) if user = db.followings.find_by_screen_name(name) then f.call user else api.delay(0) do|t| user = t.get "users/show",:screen_name=>name f.call user end end end |