Class: UrlExpander::Expanders::Bitly

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

Overview

Expand Bitly URLS Usage: UrlExpander::Client.expand(“bit.ly/qpshuI”) UrlExpander::Client.expand(“j.mp/qpshuI”) UrlExpander::Client.expand(“nyti.ms/dzy2b7”) UrlExpander::Client.expand(“tcrn.ch/oe50JN”) UrlExpander::Client.expand(“fxn.ws/pBewvL”)

Direct Known Subclasses

Foursq, Fxnws, Nytims, Tcrnch

Defined Under Namespace

Classes: Request

Constant Summary collapse

PATTERN =

NOTICE: We ignored the / before the key bit.ly/qpshuI => ‘qpshuI’ without /

%r'(http://(?:bit\.ly|j\.mp)/([\w/]+))'

Instance Attribute Summary collapse

Attributes inherited from API

#long_url, #parttern, #shortner_key

Instance Method Summary collapse

Constructor Details

#initialize(short_url, options = {}) ⇒ Bitly

Returns a new instance of Bitly.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/url_expander/expanders/api/bitly.rb', line 20

def initialize(short_url, options={})
  @parent_klass = self
  load_credentials(options[:config_file])
  
  if @login.nil? || @api_key.nil?
    raise ArgumentError.new('Bitly Expander require login, api_key. Run "rake url_expander:generate_config"')
  end
  
  super(short_url,options)
  fetch_url
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



18
19
20
# File 'lib/url_expander/expanders/api/bitly.rb', line 18

def api_key
  @api_key
end

#loginObject

Returns the value of attribute login.



18
19
20
# File 'lib/url_expander/expanders/api/bitly.rb', line 18

def 
  @login
end

#parent_klassObject (readonly)

Returns the value of attribute parent_klass.



17
18
19
# File 'lib/url_expander/expanders/api/bitly.rb', line 17

def parent_klass
  @parent_klass
end