Module: TinyUrl
- Defined in:
- lib/tiny_url.rb,
lib/tiny_url/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
Class Method Details
.tinify(url) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/tiny_url.rb', line 5 def self.tinify(url) uri = URI.parse "http://tinyurl.com/api-create.php?url=http://#{url}" http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) tiny_url = response.body puts "The generated tiny url is #{tiny_url}, you're gonna see the page..." sleep 1 `open #{tiny_url}` end |