Class: FollowersNumber::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/followers_number/parser.rb

Constant Summary collapse

MAPPING =
{
  'twitter.com' => FollowersNumber::Parsers::Twitter,
  'instagram.com' => FollowersNumber::Parsers::Instagram,
  'youtube.com' => FollowersNumber::Parsers::Youtube,
  'facebook.com' => FollowersNumber::Parsers::Facebook,
  'medium.com' => FollowersNumber::Parsers::Medium
}

Class Method Summary collapse

Class Method Details

.call(profile_url, response) ⇒ Object



11
12
13
14
15
16
# File 'lib/followers_number/parser.rb', line 11

def self.call(profile_url, response)
  html = ::Nokogiri::HTML(response.body)
  mapper = MAPPING[URI.parse(profile_url).host]

  mapper.parse(html)
end