Class: ExtraSpace::Crawl
- Inherits:
-
Object
- Object
- ExtraSpace::Crawl
- Defined in:
- lib/extraspace/crawl.rb
Overview
Handles the crawl command via CLI.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(stdout: $stdout, stderr: $stderr, url: nil) ⇒ Crawl
constructor
A new instance of Crawl.
- #process(url:) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(stdout: $stdout, stderr: $stderr, url: nil) ⇒ Crawl
Returns a new instance of Crawl.
13 14 15 16 17 |
# File 'lib/extraspace/crawl.rb', line 13 def initialize(stdout: $stdout, stderr: $stderr, url: nil) @stdout = stdout @stderr = stderr @url = url end |
Class Method Details
.run ⇒ Object
6 7 8 |
# File 'lib/extraspace/crawl.rb', line 6 def self.run(...) new(...).run end |
Instance Method Details
#process(url:) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/extraspace/crawl.rb', line 30 def process(url:) @stdout.puts(url) facility = Facility.fetch(url: url) @stdout.puts(facility.text) facility.prices.each { |price| @stdout.puts(price.text) } @stdout.puts rescue FetchError => e @stderr.puts("url=#{url} error=#{e.}") end |