Class: Snapcrawl::Screenshot
- Inherits:
-
Object
- Object
- Snapcrawl::Screenshot
- Defined in:
- lib/snapcrawl/screenshot.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ Screenshot
constructor
A new instance of Screenshot.
- #save(outfile = nil) ⇒ Object
Constructor Details
#initialize(url) ⇒ Screenshot
Returns a new instance of Screenshot.
9 10 11 |
# File 'lib/snapcrawl/screenshot.rb', line 9 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/snapcrawl/screenshot.rb', line 7 def url @url end |
Instance Method Details
#save(outfile = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/snapcrawl/screenshot.rb', line 13 def save(outfile = nil) outfile ||= "#{url.to_slug}.png" fetch_opts = { allowed_status_codes: [404, 401, 403] } if Config.selector fetch_opts[:selector] = Config.selector fetch_opts[:full] = false end webshot_capture url, outfile, fetch_opts end |