Methods

LongURL

Constants

ShortURLMatchRegexp
(Not documented)
EndPoint
Urls for longurl
ServiceEndPoint
(Not documented)

Public Class Methods

expand(url, options = {}) click to toggle source

Expand given :url to a longest one. First, expand will try to expand url using longurl.org service. Then, it will try to direct follow redirections on the given url and returns final one.

Options

  • :cache : cache object to use, must implement [] and []= functions.

Types

url is expected to be a String and returns a String with the url.

Examples

  # simple expands
  LongURL.expand("http://tinyurl.com/1c2")                              # => "http://www.google.com"
  LongURL.expand("http://tinyurl.com/blnhsg")                           # => "http://www.google.com/search?q=number+of+horns+on+a+unicorn&ie=UTF-8"
  LongURL.expand("http://is.gd/iUKg")                                   # => "http://fabien.jakimowicz.com"

  # not expandable urls
  LongURL.expand("http://www.linuxfr.org")                              # => "http://www.linuxfr.org"

Exceptions

# File lib/longurl/expand.rb, line 27
    def expand(url, options = {})
      @@expander ||= Expander.new(:cache => options[:cache])
      @@expander.expand(url)
    end

Disabled; run with $DEBUG to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.