class Sharrando::Social
Public Class Methods
list()
click to toggle source
# File lib/sharrando/social.rb, line 62 def list %i(email twitter facebook google_plus tumblr delicious linkedin pocket pinterest whatsapp) end
Public Instance Methods
delicious(url: '', title: '')
click to toggle source
# File lib/sharrando/social.rb, line 41 def delicious(url: '', title: '') "http://www.delicious.com/save?url=#{url}&title=#{title}&jump=yes&pic=#{image}" end
email(subject: '', body: '')
click to toggle source
# File lib/sharrando/social.rb, line 13 def email(subject: '', body: '') "mailto:?to=&subject=#{subject}&body=#{body.gsub("\n", "%0D%0A")}" end
facebook(title: '', url: '', description: '', image: '')
click to toggle source
# File lib/sharrando/social.rb, line 21 def facebook(title: '', url: '', description: '', image: '') if !description || description.empty? "http://www.facebook.com/sharer.php?t=#{title}&u=#{url}" else "http://www.facebook.com/sharer.php?s=100&p[url]=#{url}&p[title]=#{title}&p[summary]=#{description}&p[images][0]=#{image}" end end
google_plus(url: '', text: '')
click to toggle source
# File lib/sharrando/social.rb, line 29 def google_plus(url: '', text: '') "https://plus.google.com/share?url=#{url}&t=#{text}" end
linkedin(url: '', title: '', description: '', source: '')
click to toggle source
# File lib/sharrando/social.rb, line 45 def linkedin(url: '', title: '', description: '', source: '') "http://www.linkedin.com/shareArticle?mini=true&url=#{url}&title=#{title}&summary=#{description}&source=#{source}" end
pinterest(url: '', image: '', description: '')
click to toggle source
# File lib/sharrando/social.rb, line 53 def pinterest(url: '', image: '', description: '') "http://pinterest.com/pin/create/button/?url=#{url}&media=#{image}&description=#{description}" end
pocket(url: '')
click to toggle source
# File lib/sharrando/social.rb, line 49 def pocket(url: '') "https://getpocket.com/save?url=#{url}" end
tumblr(data_type: '', contents: '')
click to toggle source
# File lib/sharrando/social.rb, line 33 def tumblr(data_type: '', contents: '') raise ArgumentError, "Data type must be <link>, <text>, <photo> or <quote>" unless %i(link text photo quote).include? data_type "http://www.tumblr.com/share/#{data_type}?".tap do |url| (contents ||= {}).each { |key, val| url << "#{key}=#{CGI::escape(val)}&"} end end
twitter(text: '')
click to toggle source
# File lib/sharrando/social.rb, line 17 def twitter(text: '') "https://twitter.com/home?status=#{text}" end
whatsapp(description: '')
click to toggle source
# File lib/sharrando/social.rb, line 57 def whatsapp(description: '') "whatsapp://send?text=#{description}" end