Skip to content

Commit

Permalink
Remove Twitter#from_user
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jul 26, 2013
1 parent 4ef37d6 commit d2ae9f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,21 @@ The `Twitter::SearchResults` class has also been redesigned to have an
this class no longer inherits from `Twitter::Base`. As a result, the `#[]`
method has been removed without replacement.

### Users
The `Twitter::User` object has been cleaned up. The following methods have been
removed:

* `#from_user`
* `#from_user_id`
* `#from_user_name`
* `#to_user`
* `$to_user_id`
* `to_user_name`
* `profile_image_url`
* `profile_image_url_https`

These attributes can be accessed through the `#user` method.

## Configuration
Twitter API v1.1 requires you to authenticate via OAuth, so you'll need to
[register your application with Twitter][register]. Once you've registered an
Expand Down Expand Up @@ -420,7 +435,7 @@ Twitter.status(27558893223)
```ruby
Twitter.search("to:justinbieber marry me", :count => 3, :result_type => "recent").collect do |tweet|
"#{tweet.from_user}: #{tweet.text}"
"#{tweet.user.screen_name}: #{tweet.text}"
end
```
**Find a Japanese-language Tweet tagged #ruby (excluding retweets)**
Expand Down
12 changes: 3 additions & 9 deletions lib/twitter/tweet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
module Twitter
class Tweet < Twitter::Identity
include Twitter::Creatable
attr_reader :favorite_count, :favorited, :from_user_id, :from_user_name,
:in_reply_to_screen_name, :in_reply_to_attrs_id, :in_reply_to_status_id,
:in_reply_to_user_id, :lang, :retweet_count, :retweeted, :source, :text,
:to_user, :to_user_id, :to_user_name, :truncated
attr_reader :favorite_count, :favorited, :in_reply_to_screen_name,
:in_reply_to_attrs_id, :in_reply_to_status_id, :in_reply_to_user_id,
:lang, :retweet_count, :retweeted, :source, :text, :truncated
alias favorites_count favorite_count
alias favourite_count favorite_count
alias favourites_count favorite_count
Expand All @@ -23,11 +22,6 @@ def entities?
!@attrs[:entities].nil?
end

# @return [String]
def from_user
@attrs[:from_user] || user && user.screen_name
end

def filter_level
@attrs[:filter_level] || "none"
end
Expand Down
17 changes: 0 additions & 17 deletions spec/twitter/tweet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,6 @@
end
end

describe "#from_user" do
it "returns a screen name when from_user is set" do
tweet = Twitter::Tweet.new(:id => 28669546014, :from_user => "sferik")
expect(tweet.from_user).to be_a String
expect(tweet.from_user).to eq "sferik"
end
it "returns a screen name when screen_name is set" do
tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382, :screen_name => "sferik"})
expect(tweet.from_user).to be_a String
expect(tweet.from_user).to eq "sferik"
end
it "returns nil when not set" do
tweet = Twitter::Tweet.new(:id => 28669546014)
expect(tweet.from_user).to be_nil
end
end

describe "#filter_level" do
it "returns the filter level when filter_level is set" do
tweet = Twitter::Tweet.new(:id => 28669546014, :filter_level => "high")
Expand Down

0 comments on commit d2ae9f1

Please sign in to comment.