Class: ArchiveOrgLinkGrabber
Overview
Defined Under Namespace
Classes: Links
Instance Attribute Summary collapse
-
#links ⇒ Object
Returns the value of attribute links.
Instance Method Summary collapse
- #extract_links(doc) ⇒ Object
-
#initialize(urls) ⇒ ArchiveOrgLinkGrabber
constructor
A new instance of ArchiveOrgLinkGrabber.
- #process_urls(urls) ⇒ Object
- #yaml_formatted ⇒ Object
Constructor Details
#initialize(urls) ⇒ ArchiveOrgLinkGrabber
Returns a new instance of ArchiveOrgLinkGrabber.
52 53 54 |
# File 'lib/utils/extract_urls.rb', line 52 def initialize(urls) process_urls(Array(urls)) end |
Instance Attribute Details
#links ⇒ Object
Returns the value of attribute links.
50 51 52 |
# File 'lib/utils/extract_urls.rb', line 50 def links @links end |
Instance Method Details
#extract_links(doc) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/utils/extract_urls.rb', line 65 def extract_links(doc) found_links = [] doc.css('a.stealth.download-pill').each do |link| next unless link['href'] =~ /mp3$/ found_links << link['href'] end found_links end |
#process_urls(urls) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/utils/extract_urls.rb', line 56 def process_urls(urls) lnks = [] urls.each do |url| doc = Nokogiri::HTML(open(url)) lnks = lnks + extract_links(doc) end self.links = Links.new(lnks) end |
#yaml_formatted ⇒ Object
74 75 76 |
# File 'lib/utils/extract_urls.rb', line 74 def yaml_formatted links.yaml_formatted end |