Class: TwitterAccount
- Inherits:
-
Object
- Object
- TwitterAccount
- Defined in:
- lib/twitter_account.rb
Instance Attribute Summary collapse
-
#followers ⇒ Object
readonly
Returns the value of attribute followers.
-
#friends ⇒ Object
readonly
Returns the value of attribute friends.
Instance Method Summary collapse
- #direct_messages ⇒ Object
-
#friends_timeline ⇒ Object
wating for a better formating (see twitter gem bien) this methods are looking for some factoring.
-
#initialize ⇒ TwitterAccount
constructor
A new instance of TwitterAccount.
- #replies ⇒ Object
- #update(msg) ⇒ Object
- #updates ⇒ Object
- #user_timeline(user) ⇒ Object
Constructor Details
#initialize ⇒ TwitterAccount
Returns a new instance of TwitterAccount.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/twitter_account.rb', line 7 def initialize config = ConfigStore.new("#{ENV['HOME']}/.twitter") httpauth = Twitter::HTTPAuth.new(config['email'], config['password']) @account = Twitter::Base.new(httpauth) @friends = @account.friends.map do |friend| friend.screen_name end @followers = @account.followers.map do |follower| follower.screen_name end end |
Instance Attribute Details
#followers ⇒ Object (readonly)
Returns the value of attribute followers.
5 6 7 |
# File 'lib/twitter_account.rb', line 5 def followers @followers end |
#friends ⇒ Object (readonly)
Returns the value of attribute friends.
5 6 7 |
# File 'lib/twitter_account.rb', line 5 def friends @friends end |
Instance Method Details
#direct_messages ⇒ Object
28 29 30 31 |
# File 'lib/twitter_account.rb', line 28 def texts = @account..map {|t| "#{t.sender.screen_name}> #{t.text}"} texts.join("\n") + "\n" end |
#friends_timeline ⇒ Object
wating for a better formating (see twitter gem bien) this methods are looking for some factoring
23 24 25 26 |
# File 'lib/twitter_account.rb', line 23 def friends_timeline texts = @account.friends_timeline.map {|t| "#{t.user.screen_name}> #{t.text}"} texts.join("\n") + "\n" end |
#replies ⇒ Object
38 39 40 41 |
# File 'lib/twitter_account.rb', line 38 def replies texts = @account.replies.map {|t| "#{t.user.screen_name}> #{t.text}"} texts.join("\n") + "\n" end |
#update(msg) ⇒ Object
43 44 45 |
# File 'lib/twitter_account.rb', line 43 def update(msg) @account.update msg end |
#updates ⇒ Object
33 34 35 36 |
# File 'lib/twitter_account.rb', line 33 def updates texts = @account.user_timeline.map {|t| "#{t.user.screen_name}> #{t.text}"} texts.join("\n") + "\n" end |
#user_timeline(user) ⇒ Object
47 48 49 50 |
# File 'lib/twitter_account.rb', line 47 def user_timeline(user) texts = Twitter::Search.new(user).map {|t| "#{t.from_user}> #{t.text}"} texts.join("\n") + "\n" end |