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 166 166: def self.shorten(url, service = :rubyurl) 167: if valid_services.include? service 168: @@services[service].call(url) 169: else 170: raise InvalidService 171: end 172: end
Returns @@valid_services
# File lib/shorturl.rb, line 137 137: def self.valid_services 138: @@valid_services 139: end