class TwitterWebIntents::Intents

Constants

URL_BASE

dev.twitter.com/docs/intents

Public Class Methods

get_favorite_url(params) click to toggle source
# File lib/twitter_web_intents/intents.rb, line 30
def get_favorite_url(params)
  get_intent(:favorite, params, [:tweet_id, :related])
end
get_profile_url(screen_name) click to toggle source
# File lib/twitter_web_intents/intents.rb, line 18
def get_profile_url(screen_name)
  URL_BASE + screen_name
end
get_retweet_url(params) click to toggle source
# File lib/twitter_web_intents/intents.rb, line 38
def get_retweet_url(params)
  get_intent(:retweet, params, [:tweet_id, :related])
end
get_search_url(query) click to toggle source
# File lib/twitter_web_intents/intents.rb, line 14
def get_search_url(query)
  URL_BASE + "search?q=" + URI.escape(query)
end
get_status_url(screen_name, user_id) click to toggle source
# File lib/twitter_web_intents/intents.rb, line 22
def get_status_url(screen_name, user_id)
  URL_BASE + "#{screen_name}/status/#{user_id}"
end
get_tweet_url(params) click to toggle source
# File lib/twitter_web_intents/intents.rb, line 34
def get_tweet_url(params)
  get_intent(:tweet, params, [:url, :via, :text, :in_reply_to, :hashtags, :related])
end
get_user_url(params) click to toggle source
# File lib/twitter_web_intents/intents.rb, line 26
def get_user_url(params)
  get_intent(:user, params, [:screen_name, :user_id])
end

Private Class Methods

get_intent(type, params, valid) click to toggle source
# File lib/twitter_web_intents/intents.rb, line 44
def get_intent(type, params, valid)
  URL_BASE + "intent/#{type.to_s}?#{get_parameters(type, params, valid).to_query}"
end
get_parameters(type, params, valid) click to toggle source
# File lib/twitter_web_intents/intents.rb, line 48
def get_parameters(type, params, valid)
  counts = {}; hash = {}
  params.each do |k,v|
    raise ArgumentException.new("The parameter #{k} is not supported by the #{type} intent") if not valid.include?(k)
    counts[k] = (counts[k].nil?) ? 1 : counts[k] += 1
    hash[k] = v.is_a?(Array) ? v.join(",") : v
  end
  hash
end