Class: Tweetwine::UrlShortener
- Inherits:
-
Object
- Object
- Tweetwine::UrlShortener
- Defined in:
- lib/tweetwine/url_shortener.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ UrlShortener
constructor
A new instance of UrlShortener.
- #shorten(url) ⇒ Object
Constructor Details
#initialize(options) ⇒ UrlShortener
Returns a new instance of UrlShortener.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tweetwine/url_shortener.rb', line 5 def initialize() raise 'UrlShortener should be disabled' if [:disable] require 'nokogiri' @method = ([:method] || :get).to_sym unless [:get, :post].include? @method raise CommandLineError, "Unsupported HTTP request method for URL shortening: #{@method}" end @service_url = require_option , :service_url @url_param_name = require_option , :url_param_name @xpath_selector = require_option , :xpath_selector @extra_params = [:extra_params] || {} if @method == :get tmp = [] @extra_params.each_pair { |k, v| tmp << "#{k}=#{v}" } @extra_params = tmp end end |