class UrlExpander::Expanders::Decenturl

Expand Budurl URLS Usage: UrlExpander::Client.expand(“decenturl.com/youtube/medieval”) UrlExpander::Client.expand(“youtube.decenturl.com/medieval”)

Constants

PATTERN

NOTICE: We ignored the / before the key decenturl.com/youtube/medieval => 'youtube/medieval' without /

Attributes

parent_klass[R]
short_url[R]

Public Class Methods

new(short_url, options={}) click to toggle source
# File lib/url_expander/expanders/api/decenturl.rb, line 17
def initialize(short_url, options={})
  @parent_klass = self
  @short_url = short_url
  fetch_url
end

Private Instance Methods

fetch_url() click to toggle source
# File lib/url_expander/expanders/api/decenturl.rb, line 32
def fetch_url
  data = JSON.parse Request.get("/api-resolve?d=#{@short_url}").response.body
  if(data.include?("ok"))
    @long_url = data[1]
  else
    raise UrlExpander::Error.new(data.join(","),404)
  end
end