Class: WebMole::Scraper
- Inherits:
-
Object
- Object
- WebMole::Scraper
- Defined in:
- lib/webmole/scraper.rb
Instance Attribute Summary collapse
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
Instance Method Summary collapse
-
#initialize(scrape_option, pattern, gathering_mode = false) ⇒ Scraper
constructor
A new instance of Scraper.
- #scrape(text, url) ⇒ Object
Constructor Details
#initialize(scrape_option, pattern, gathering_mode = false) ⇒ Scraper
Returns a new instance of Scraper.
7 8 9 10 11 12 |
# File 'lib/webmole/scraper.rb', line 7 def initialize(scrape_option, pattern, gathering_mode = false) @scrape_option = scrape_option @pattern = pattern ? Regexp.new(pattern) : nil @matches = Hash.new { |h, k| h[k] = Set.new } @gathering_mode = gathering_mode end |
Instance Attribute Details
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
5 6 7 |
# File 'lib/webmole/scraper.rb', line 5 def matches @matches end |
Instance Method Details
#scrape(text, url) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/webmole/scraper.rb', line 14 def scrape(text, url) case @scrape_option when :emails find_emails(text, url) when :phone_numbers find_phone_numbers(text, url) when :urls find_urls(text, url) when :social_media (text, url) when :addresses find_addresses(text, url) when :credit_cards find_credit_cards(text, url) when :custom find_matches(text, url) end end |