Class: Popularity::Soundcloud
- Inherits:
-
Crawler
- Object
- Crawler
- Popularity::Soundcloud
show all
- Defined in:
- lib/popularity/networks/soundcloud.rb
Instance Attribute Summary
Attributes inherited from Crawler
#url
Instance Method Summary
collapse
Methods inherited from Crawler
#async_done?, #fetch, #fetch_async, #has_response?, #host, #initialize, #name, #response, #to_json
Instance Method Details
#as_json(options = {}) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/popularity/networks/soundcloud.rb', line 19
def as_json(options = {})
{"plays" => plays,
"likes" => likes,
"comments" => ,
"downloads" => downloads }
end
|
11
12
13
|
# File 'lib/popularity/networks/soundcloud.rb', line 11
def
response.scan(/\"soundcloud:comments_count\" content=\"([0-9]*)\"/).flatten.first.to_f.to_i
end
|
#downloads ⇒ Object
15
16
17
|
# File 'lib/popularity/networks/soundcloud.rb', line 15
def downloads
response.scan(/\"soundcloud:download_count\" content=\"([0-9]*)\"/).flatten.first.to_f.to_i
end
|
#likes ⇒ Object
7
8
9
|
# File 'lib/popularity/networks/soundcloud.rb', line 7
def likes
response.scan(/\"soundcloud:like_count\" content=\"([0-9]*)\"/).flatten.first.to_f.to_i
end
|
#plays ⇒ Object
3
4
5
|
# File 'lib/popularity/networks/soundcloud.rb', line 3
def plays
response.scan(/\"soundcloud:play_count\" content=\"([0-9]*)\"/).flatten.first.to_f.to_i
end
|
#total ⇒ Object
26
27
28
|
# File 'lib/popularity/networks/soundcloud.rb', line 26
def total
plays + likes + downloads +
end
|
#valid? ⇒ Boolean
30
31
32
|
# File 'lib/popularity/networks/soundcloud.rb', line 30
def valid?
host == 'soundcloud.com'
end
|