Class: Twitterland::Mrtweet
- Inherits:
-
Object
- Object
- Twitterland::Mrtweet
- Includes:
- HTTParty
- Defined in:
- lib/twitterland/mrtweet.rb
Instance Attribute Summary (collapse)
-
- (Object) is_user
readonly
Check whether the given user is a MrTweet user (always call API).
-
- (Object) most_attention_towards
readonly
Most attention towards.
-
- (Object) profile
readonly
Returns MrTweet statistics of the given user.
-
- (Object) recommendations
readonly
Returns the latest recommendations the given user received on MrTweet.
Instance Method Summary (collapse)
-
- (Mrtweet) initialize(api_key, username)
constructor
get your api key at api.mrtweet.com/newapi.
-
- (Boolean) is_user?
Check whether the given user is a MrTweet user (caches first request).
-
- (Object) recommend(reason, friend_name)
Recommend a user.
Constructor Details
- (Mrtweet) initialize(api_key, username)
get your api key at api.mrtweet.com/newapi
10 11 12 13 14 |
# File 'lib/twitterland/mrtweet.rb', line 10 def initialize(api_key, username) @username = username @api_key = api_key @is_user = self.is_user end |
Instance Attribute Details
- (Object) is_user (readonly)
Check whether the given user is a MrTweet user (always call API)
Twitterland::Mrtweet.new(api_key,'bradleyjoyce').is_user
19 20 21 |
# File 'lib/twitterland/mrtweet.rb', line 19 def is_user Hashie::Mash.new(self.class.get("/is_user/#{@username}/#{@api_key}.json")).is_user end |
- (Object) most_attention_towards (readonly)
Most attention towards
Twitterland::Mrtweet.new(api_key,'bradleyjoyce').most_attention_towards
52 53 54 55 56 |
# File 'lib/twitterland/mrtweet.rb', line 52 def most_attention_towards if is_user? @most_attention_towards ||= Hashie::Mash.new(self.class.get("/most_attention_towards/#{@username}/#{@api_key}.json")).most_attention_towards end end |
- (Object) profile (readonly)
Returns MrTweet statistics of the given user
Twitterland::Mrtweet.new(api_key,'bradleyjoyce').profile
33 34 35 36 37 |
# File 'lib/twitterland/mrtweet.rb', line 33 def profile if is_user? @profile ||= Hashie::Mash.new(self.class.get("/profile/#{@username}/#{@api_key}.json")).profile end end |
- (Object) recommendations (readonly)
Returns the latest recommendations the given user received on MrTweet
Twitterland::Mrtweet.new(api_key,'bradleyjoyce').recommendations
42 43 44 45 46 |
# File 'lib/twitterland/mrtweet.rb', line 42 def recommendations if is_user? @recommendations ||= Hashie::Mash.new(self.class.get("/recommendations/#{@username}/#{@api_key}.json")).recommendations end end |
Instance Method Details
- (Boolean) is_user?
Check whether the given user is a MrTweet user (caches first request)
Twitterland::Mrtweet.new(api_key,'bradleyjoyce').is_user?
26 27 28 |
# File 'lib/twitterland/mrtweet.rb', line 26 def is_user? @is_user ||= self.is_user end |
- (Object) recommend(reason, friend_name)
Recommend a user
reason = "Wynn is an awesome entrepreneur, rubyist, designer and friend! Follow him for his useful and entertaining tweets!"
friend_name = "pengwynn"
Twitterland::Mrtweet.new(api_key,'bradleyjoyce').recommend(reason,friend_name)
63 64 65 66 67 |
# File 'lib/twitterland/mrtweet.rb', line 63 def recommend(reason, friend_name) if is_user? Hashie::Mash.new(self.class.post("/recommend/#{@username}/#{@api_key}.json", :body => { :reason => reason, :friend_name => friend_name})).status == "success" end end |