Class: PhishTank::FeedRequest
- Inherits:
-
Object
- Object
- PhishTank::FeedRequest
- Defined in:
- lib/phishtank/feed_request.rb
Instance Attribute Summary collapse
-
#etag ⇒ Object
Returns the value of attribute etag.
Instance Method Summary collapse
- #get(uri, opts = {}) ⇒ Object
- #get_update ⇒ Object
- #head(uri, opts = {}) ⇒ Object
-
#initialize(etag = nil) ⇒ FeedRequest
constructor
A new instance of FeedRequest.
- #update? ⇒ Boolean
- #update_uri ⇒ Object
Constructor Details
#initialize(etag = nil) ⇒ FeedRequest
Returns a new instance of FeedRequest.
5 6 7 |
# File 'lib/phishtank/feed_request.rb', line 5 def initialize(etag = nil) @etag = etag || PhishTank.configuration.etag end |
Instance Attribute Details
#etag ⇒ Object
Returns the value of attribute etag.
3 4 5 |
# File 'lib/phishtank/feed_request.rb', line 3 def etag @etag end |
Instance Method Details
#get(uri, opts = {}) ⇒ Object
30 31 32 |
# File 'lib/phishtank/feed_request.rb', line 30 def get(uri, opts = {}) Typhoeus::Request.get(uri, opts) end |
#get_update ⇒ Object
15 16 17 18 19 20 |
# File 'lib/phishtank/feed_request.rb', line 15 def get_update response = get(update_uri) file = File.new("#{PhishTank.configuration.temp_directory}/online-valid.xml", 'w') file.puts response.body file.close end |
#head(uri, opts = {}) ⇒ Object
26 27 28 |
# File 'lib/phishtank/feed_request.rb', line 26 def head(uri, opts = {}) Typhoeus::Request.head(uri, opts) end |
#update? ⇒ Boolean
9 10 11 12 13 |
# File 'lib/phishtank/feed_request.rb', line 9 def update? return true if @etag.nil? response = head(update_uri, :headers => {"ETag" => @etag}) response.headers_hash['Etag'] != "\"#{@etag}\"" end |
#update_uri ⇒ Object
22 23 24 |
# File 'lib/phishtank/feed_request.rb', line 22 def update_uri "#{BASE_URI}/data/#{PhishTank.configuration.api_key}/online-valid.xml" end |