Class: Textminer::Miner
- Inherits:
-
Object
- Object
- Textminer::Miner
- Defined in:
- lib/textminer/miner.rb
Overview
:nodoc:
Instance Attribute Summary (collapse)
-
- (Object) url
Returns the value of attribute url.
Instance Method Summary (collapse)
-
- (Miner) initialize(url)
constructor
A new instance of Miner.
- - (Object) perform
Constructor Details
- (Miner) initialize(url)
Returns a new instance of Miner
16 17 18 |
# File 'lib/textminer/miner.rb', line 16 def initialize(url) self.url = url end |
Instance Attribute Details
- (Object) url
Returns the value of attribute url
14 15 16 |
# File 'lib/textminer/miner.rb', line 14 def url @url end |
Instance Method Details
- (Object) perform
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/textminer/miner.rb', line 20 def perform conn = Faraday.new self.url do |c| c.use FaradayMiddleware::FollowRedirects c.adapter :net_http end if is_elsevier_wiley(self.url) res = conn.get do |req| req.headers['CR-Clickthrough-Client-Token'] = Textminer.tdm_key end else res = conn.get end type = detect_type(res) path = make_path(type) write_disk(res, path) return Mined.new(self.url, path, type) end |