Class: Phishtank::Scanner
- Inherits:
-
Object
- Object
- Phishtank::Scanner
- Defined in:
- lib/phishtank/scanner.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Instance Method Summary collapse
-
#initialize(api_key) ⇒ Scanner
constructor
A new instance of Scanner.
- #scan(url) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Scanner
Returns a new instance of Scanner.
5 6 7 8 |
# File 'lib/phishtank/scanner.rb', line 5 def initialize(api_key) @api_key = api_key @format = 'json' end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
3 4 5 |
# File 'lib/phishtank/scanner.rb', line 3 def format @format end |
Instance Method Details
#scan(url) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/phishtank/scanner.rb', line 10 def scan(url) # Init parser client = Phishtank::Raw.new(@api_key, @format) response = JSON.parse(client.check_url(url), :symbolize_names => true) # Validate server response if response[:meta][:status] == 'success' # Request Succeeded return Phishtank::Parser.new(response) else raise Exception.new('Bad Response from Phishtank.') end end |