Class: Phishtank::DB
- Inherits:
-
Object
- Object
- Phishtank::DB
- Defined in:
- lib/phishtank/db.rb
Instance Method Summary collapse
-
#download ⇒ Object
Get the database snapshot from Phishtank.com.
-
#initialize(api_key, format = 'json', compression = nil) ⇒ DB
constructor
A new instance of DB.
Constructor Details
#initialize(api_key, format = 'json', compression = nil) ⇒ DB
Returns a new instance of DB.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/phishtank/db.rb', line 3 def initialize(api_key, format='json', compression=nil) @api_key = api_key formats = ['json', 'csv', 'php_serialized', 'xml'] compressions = ['gz', 'bz2'] # Validate formats if (formats.include?(format)) @format = format else raise Exception.new("Unknown data format. Please use one of the following: #{formats}") end # Validate compression methods if (compressions.include?(compression)) @compression = compression elsif compression.nil? @compression = '' else raise Exception.new("Unknown compression method. Please use one of the following: #{compressions} or none (nil)") end end |
Instance Method Details
#download ⇒ Object
Get the database snapshot from Phishtank.com
27 28 29 30 |
# File 'lib/phishtank/db.rb', line 27 def download api_url = build_url RestClient::Request.execute(method: 'GET', url: api_url, open_timeout: 20) end |