class ShareCount::Base
Constants
- DEFAULT_OPEN_TIMEOUT
- DEFAULT_TIMEOUT
Attributes
checked_url[RW]
Public Class Methods
config=(val)
click to toggle source
# File lib/share_count/base.rb, line 10 def config=(val) @@config = val end
new(checked_url)
click to toggle source
# File lib/share_count/base.rb, line 17 def initialize(checked_url) # remove URI fragment @checked_url = checked_url.gsub(/#.+$/, '') end
Public Instance Methods
Protected Instance Methods
config_name()
click to toggle source
# File lib/share_count/base.rb, line 35 def config_name to_underscore(self.class.name.split('::').last).to_sym end
get(url, params)
click to toggle source
# File lib/share_count/base.rb, line 47 def get(url, params) RestClient::Resource.new(url, timeout: timeout, open_timeout: open_timeout).get(params) end
open_timeout()
click to toggle source
# File lib/share_count/base.rb, line 43 def open_timeout (@@config[config_name] || {})[:open_timeout] || DEFAULT_OPEN_TIMEOUT end
post(url, params, headers = {})
click to toggle source
# File lib/share_count/base.rb, line 51 def post(url, params, headers = {}) RestClient::Resource.new(url, timeout: timeout, open_timeout: open_timeout).post(params, headers) end
timeout()
click to toggle source
# File lib/share_count/base.rb, line 39 def timeout (@@config[config_name] || {})[:timeout] || DEFAULT_TIMEOUT end