Class: SocialsRegex::Extraction

Inherits:
Object
  • Object
show all
Defined in:
lib/socials_regex/socials.rb

Overview

Extracted profiles.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:) ⇒ Extraction

Returns a new instance of Extraction.



39
40
41
# File 'lib/socials_regex/socials.rb', line 39

def initialize(text:)
  @text = text
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



37
38
39
# File 'lib/socials_regex/socials.rb', line 37

def text
  @text
end

Instance Method Details

#extract_matches_by_platform(platform:) ⇒ Object

Find all matches for a specific platform. :param platform: platform to search for. :return: hash of list of matches.



63
64
65
66
67
68
# File 'lib/socials_regex/socials.rb', line 63

def extract_matches_by_platform(platform:)
  regexes = Socials::PLATFORMS_REGEX[platform.to_sym]
  raise Socials::ERROR_MSG_UNKNOWN_PLATFORM unless regexes

  platform_matches(regexes: regexes, platform: platform)
end

#extract_matches_by_regex(regex:) ⇒ Object

Find all matches for a specific regex. :param regex: platform to search for. :return: list of matches.



56
57
58
# File 'lib/socials_regex/socials.rb', line 56

def extract_matches_by_regex(regex:)
  matches(regex: regex)
end

#extract_matches_per_platformObject

Get lists of profiles keyed by platform name. :return: a dictionary with the platform as a key, and a list of the platform’s profiles as values.



45
46
47
48
49
50
51
# File 'lib/socials_regex/socials.rb', line 45

def extract_matches_per_platform
  matches = {}
  Socials::PLATFORMS_REGEX.each do |platform, regexes|
    matches.merge!(platform_matches(regexes: regexes, platform: platform))
  end
  matches
end