Created
January 10, 2009 15:48
-
-
Save maccman/45475 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TwitterBinder < Binder::Collection | |
class << self | |
# What about filters - should they be implemented? | |
# | |
# I also feel this is lacking 'views'. | |
# There should be a view for the index, and the login | |
# There should also be an easy api in ruby/js for switching views | |
def index | |
self.items = twit.timeline(:user) | |
end | |
# This is something I made up | |
# but it would be nice | |
add_timer :index, 30 | |
def update(text) | |
twit.update(text) | |
index # update timeline | |
end | |
# There might be a nicer way to do | |
# this, but I can't find it | |
def logged_in? | |
begin | |
twit.timeline && true | |
rescue Twitter::CantConnect | |
false | |
end | |
end | |
cattr_accessor :user, :pass | |
def login(user, pass) | |
self.user, self.pass = user, pass | |
end | |
protected | |
def twit | |
Twitter::Base.new(self.user, self.pass) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment