Module: ShareCount
- Includes:
- StringHelper
- Included in:
- SocialShareFeature::Count
- Defined in:
- lib/share_count.rb,
lib/share_count/base.rb,
lib/share_count/weibo.rb,
lib/share_count/google.rb,
lib/share_count/reddit.rb,
lib/share_count/twitter.rb,
lib/share_count/facebook.rb,
lib/share_count/linkedin.rb,
lib/share_count/pinterest.rb,
lib/share_count/string_helper.rb
Defined Under Namespace
Modules: StringHelper
Classes: Base, Facebook, Google, Linkedin, Pinterest, Reddit, Twitter, Weibo
Constant Summary
collapse
- NETWORK_LIST =
[
:facebook,
:google,
:reddit,
:weibo
]
Instance Method Summary
collapse
#to_camel_case, #to_underscore
Instance Method Details
#all(url) ⇒ Object
52
53
54
|
# File 'lib/share_count.rb', line 52
def all(url)
selected(url, NETWORK_LIST)
end
|
#all!(url) ⇒ Object
55
56
57
|
# File 'lib/share_count.rb', line 55
def all!(url)
selected!(url, NETWORK_LIST)
end
|
#config=(val) ⇒ Object
15
16
17
|
# File 'lib/share_count.rb', line 15
def config=(val)
ShareCount::Base.config = val
end
|
#has_any?(url, selected_networks = NETWORK_LIST) ⇒ Boolean
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/share_count.rb', line 61
def has_any?(url, selected_networks = NETWORK_LIST)
lambdas = filtered_networks(selected_networks).map do |network_name|
-> {self.send("#{network_name}!", url)}
end
pool = thread_pool(lambdas)
found = false
while !pool.empty? && !found
sleep 0.05
if thread = pool.find(&:stop?)
if thread.value > 0
pool.each(&:kill)
found = true
else
pool.delete(thread)
end
end
end
found
end
|
#omit(url, excluded_networks = []) ⇒ Object
40
41
42
|
# File 'lib/share_count.rb', line 40
def omit(url, excluded_networks = [])
selected_base(url, NETWORK_LIST.map(&:to_s) - excluded_networks.map(&:to_s), false)
end
|
#omit!(url, excluded_networks = []) ⇒ Object
43
44
45
|
# File 'lib/share_count.rb', line 43
def omit!(url, excluded_networks = [])
selected_base(url, NETWORK_LIST.map(&:to_s) - excluded_networks.map(&:to_s), true)
end
|
#selected(url, selected_networks) ⇒ Object
46
47
48
|
# File 'lib/share_count.rb', line 46
def selected(url, selected_networks)
selected_base(url, selected_networks, false)
end
|
#selected!(url, selected_networks) ⇒ Object
49
50
51
|
# File 'lib/share_count.rb', line 49
def selected!(url, selected_networks)
selected_base(url, selected_networks, true)
end
|
#supported_networks ⇒ Object
27
28
29
|
# File 'lib/share_count.rb', line 27
def supported_networks
NETWORK_LIST
end
|
#total(url, selected_networks = NETWORK_LIST) ⇒ Object
58
59
60
|
# File 'lib/share_count.rb', line 58
def total(url, selected_networks = NETWORK_LIST)
selected!(url, selected_networks).values.reduce(:+)
end
|