Class: Gtin2atc::Downloader
- Inherits:
-
Object
- Object
- Gtin2atc::Downloader
- Defined in:
- lib/gtin2atc/downloader.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #init ⇒ Object
-
#initialize(options = {}, url = nil) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(options = {}, url = nil) ⇒ Downloader
Returns a new instance of Downloader.
38 39 40 41 42 43 44 45 |
# File 'lib/gtin2atc/downloader.rb', line 38 def initialize(={}, url=nil) @options = @url = url @retry_times = 3 HTTPI.log = false # disable httpi warning Gtin2atc.log "Downloader from #{@url} for #{self.class}" init end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
37 38 39 |
# File 'lib/gtin2atc/downloader.rb', line 37 def type @type end |
Instance Method Details
#init ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gtin2atc/downloader.rb', line 46 def init @agent = Mechanize.new @agent.user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0' @agent.redirect_ok = true @agent.redirection_limit = 5 @agent. = true if RUBY_PLATFORM =~ /mswin|mingw|bccwin|cygwin/i and ENV['SSL_CERT_FILE'].nil? cert_store = OpenSSL::X509::Store.new cert_store.add_file(File.('../../../tools/cacert.pem', __FILE__)) @agent.cert_store = cert_store end Util.debug_msg "Downloader @agent ist #{@agent}" end |