Class WWW::ShortURL
In: lib/shorturl.rb
Parent: Object

Methods

Public Class methods

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:

  • :d62
  • :fyad
  • :linktrim
  • :littlink
  • :lns
  • :metamark
  • :minilink
  • :orz
  • :rubyurl
  • :shiturl
  • :shorterlink
  • :shortify
  • :shurl
  • :tinyurl

call-seq:

  ShortURL.shorten("http://mypage.com") => Uses RubyURL
  ShortURL.shorten("http://mypage.com", :tinyurl)

[Source]

     # 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

[Source]

     # File lib/shorturl.rb, line 137
137:     def self.valid_services
138:       @@valid_services
139:     end

[Validate]