Class: FakeTwitter::TweetFactory
- Inherits:
-
Object
- Object
- FakeTwitter::TweetFactory
- Defined in:
- lib/faketwitter.rb
Constant Summary collapse
- DEFAULTS =
{ "text"=>"just some tweet", "from_user"=>"jojo", "to_user_id"=>nil, "iso_language_code"=>"en", "source"=>'<a href="http://twitter.com/">web</a>', }
Class Method Summary collapse
Class Method Details
.create(attributes) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/faketwitter.rb', line 128 def create(attributes) tweet = DEFAULTS.merge(attributes.stringify_keys) clean_user_names(tweet) tweet['id'] ||= counter(:id) tweet['from_user_id'] ||= user_id_for(tweet['from_user']) tweet['to_user_id'] ||= user_id_for(tweet['to_user']) tweet['profile_image_url'] ||= "http://s3.amazonaws.com/twitter_production/profile_images/#{tweet['from_user_id']}/photo.jpg" tweet['created_at'] ||= Time.now tweet_repo << tweet tweet end |
.reset ⇒ Object
122 123 124 125 126 |
# File 'lib/faketwitter.rb', line 122 def reset @counter = nil @users = nil @tweet_repo = nil end |
.tweets_from(user) ⇒ Object
141 142 143 |
# File 'lib/faketwitter.rb', line 141 def tweets_from(user) tweet_repo.select { |tweet| tweet['from_user'] == user } end |