Class: TotenDev::Shortener

Inherits:
Object
  • Object
show all
Defined in:
lib/tdev_shortener.rb

Class Method Summary collapse

Class Method Details

.short_url(long_url) ⇒ Object



12
13
14
15
16
# File 'lib/tdev_shortener.rb', line 12

def self.short_url( long_url )
  base_url = URI( 'http://www.tdev.mobi/create/' )
  response = Net::HTTP.post_form( base_url, 'link' => long_url )
  response
end

.shorten(long_url) ⇒ Object



7
8
9
10
# File 'lib/tdev_shortener.rb', line 7

def self.shorten( long_url )
  r = short_url( long_url )
  return r.code.to_i, r.body
end