Class: UrlExpander::Expanders::Bitly
- 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”)
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
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#login ⇒ Object
Returns the value of attribute login.
-
#parent_klass ⇒ Object
readonly
Returns the value of attribute parent_klass.
Attributes inherited from API
#long_url, #parttern, #shortner_key
Instance Method Summary collapse
-
#initialize(short_url, options = {}) ⇒ Bitly
constructor
A new instance of Bitly.
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, ={}) @parent_klass = self load_credentials([: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,) fetch_url end |
Instance Attribute Details
#api_key ⇒ Object
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 |
#login ⇒ Object
Returns the value of attribute login.
18 19 20 |
# File 'lib/url_expander/expanders/api/bitly.rb', line 18 def login @login end |
#parent_klass ⇒ Object (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 |