Class: ShareCount::Base

Inherits:
Object
  • Object
show all
Includes:
StringHelper
Defined in:
lib/share_count/base.rb

Direct Known Subclasses

Facebook, Google, Linkedin, Pinterest, Reddit, Twitter, Weibo

Constant Summary collapse

DEFAULT_TIMEOUT =
3
DEFAULT_OPEN_TIMEOUT =
3
@@config =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from StringHelper

#to_camel_case, #to_underscore

Constructor Details

#initialize(checked_url) ⇒ Base

Returns a new instance of Base.



17
18
19
20
# File 'lib/share_count/base.rb', line 17

def initialize(checked_url)
  # remove URI fragment
  @checked_url = checked_url.gsub(/#.+$/, '')
end

Instance Attribute Details

#checked_urlObject

Returns the value of attribute checked_url.



15
16
17
# File 'lib/share_count/base.rb', line 15

def checked_url
  @checked_url
end

Class Method Details

.config=(val) ⇒ Object



10
11
12
# File 'lib/share_count/base.rb', line 10

def config=(val)
  @@config = val
end

Instance Method Details

#sharesObject



22
23
24
25
26
27
# File 'lib/share_count/base.rb', line 22

def shares
  shares!
rescue => e
  puts "[#{self.class.name}] Error during requesting sharings of '#{checked_url}': #{e}"
  nil
end

#shares!Object

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/share_count/base.rb', line 29

def shares!
  raise NotImplementedError
end