Class | WWW::ShortURL |
In: |
lib/shorturl.rb
|
Parent: | Object |
Main method of ShortURL, its usage is quite simple, just give an url to shorten and an optional service. If no service is selected, RubyURL.com will be used. An invalid service symbol will raise an ArgumentError exception
Valid service values:
call-seq:
ShortURL.shorten("http://mypage.com") => Uses RubyURL ShortURL.shorten("http://mypage.com", :tinyurl)
# File lib/shorturl.rb, line 202 202: def self.shorten(url, service = :rubyurl) 203: if valid_services.include? service 204: @@services[service].call(url) 205: else 206: raise InvalidService 207: end 208: end
Returns @@valid_services
# File lib/shorturl.rb, line 169 169: def self.valid_services 170: @@valid_services 171: end