Class: Botz::Downloader

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model
Defined in:
lib/botz/downloader.rb

Overview

This class is responsible for actually making a network connection and downloading hypertext

Constant Summary collapse

USER_AGENT =
[
  'Mozilla/5.0',
  '(Macintosh; Intel Mac OS X 10_12_6)',
  'AppleWebKit/537.36',
  '(KHTML, like Gecko)',
  'Chrome/64.0.3282.186',
  'Safari/537.36'
].join(' ')

Instance Method Summary collapse

Constructor Details

#initialize(name, context = nil) ⇒ Downloader

Returns a new instance of Downloader.



36
37
38
# File 'lib/botz/downloader.rb', line 36

def initialize(name, context = nil)
  super(loader: loaders[name], context: context)
end

Instance Method Details

#call(url, &block) ⇒ Object



40
41
42
# File 'lib/botz/downloader.rb', line 40

def call(url, &block)
  loader.call(context, url, block)
end