Class: Twitterland::Mrtweet

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/twitterland/mrtweet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, username) ⇒ Mrtweet

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

#is_userObject (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

#most_attention_towardsObject (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

#profileObject (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

#recommendationsObject (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

#is_user?Boolean

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

#recommend(reason, friend_name) ⇒ Object

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