Class: UrlExpander::Expanders::API

Inherits:
Object
  • Object
show all
Defined in:
lib/url_expander/expanders/api.rb

Direct Known Subclasses

Bitly, Budurl, Cligs, Decenturl, Dldbz, Googl, Isgd, Xrlus

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(short_url = "", options = {}) ⇒ API

Called from the Subclasses, its only job to set the @shortner_key For example, if the short_url = ‘bit.ly/k3irb0’ then @shortner_key = ‘k3irb0



12
13
14
15
16
17
18
# File 'lib/url_expander/expanders/api.rb', line 12

def initialize(short_url="", options={})
  if short_url.match(parent_klass.class::PATTERN)
    @shortner_key = $2
  else
    raise 'invalid pattern'
  end
end

Instance Attribute Details

#long_urlObject

Returns the value of attribute long_url.



6
7
8
# File 'lib/url_expander/expanders/api.rb', line 6

def long_url
  @long_url
end

#parent_klassObject (readonly)

Returns the value of attribute parent_klass.



7
8
9
# File 'lib/url_expander/expanders/api.rb', line 7

def parent_klass
  @parent_klass
end

#partternObject (readonly)

Returns the value of attribute parttern.



7
8
9
# File 'lib/url_expander/expanders/api.rb', line 7

def parttern
  @parttern
end

#shortner_keyObject (readonly)

Returns the value of attribute shortner_key.



7
8
9
# File 'lib/url_expander/expanders/api.rb', line 7

def shortner_key
  @shortner_key
end