Class: Popularity::Soundcloud

Inherits:
Crawler
  • Object
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

Constructor Details

This class inherits a constructor from Popularity::Crawler

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" => comments,
   "downloads" => downloads }
end

#commentsObject



11
12
13
# File 'lib/popularity/networks/soundcloud.rb', line 11

def comments
  response.scan(/\"soundcloud:comments_count\" content=\"([0-9]*)\"/).flatten.first.to_f.to_i
end

#downloadsObject



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

#likesObject



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

#playsObject



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

#totalObject



26
27
28
# File 'lib/popularity/networks/soundcloud.rb', line 26

def total
  plays + likes + downloads + comments
end

#valid?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/popularity/networks/soundcloud.rb', line 30

def valid?
  host == 'soundcloud.com'
end