Class: Shodan::Clients::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/shodan/clients/base.rb

Direct Known Subclasses

Account, Alert, DNS, Exploits, Host, Labs, Query, REST, Scan, Tools

Constant Summary collapse

HOST =

The path to the REST API endpoint.

"api.shodan.io"
BASE_URL =
"https://#{HOST}"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key: ENV["SHODAN_API_KEY"]) ⇒ Base

Returns a new instance of Base.



16
17
18
19
# File 'lib/shodan/clients/base.rb', line 16

def initialize(key: ENV["SHODAN_API_KEY"])
  @key = key
  warn 'No key has been found or provided!' unless key?
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



14
15
16
# File 'lib/shodan/clients/base.rb', line 14

def key
  @key
end

Instance Method Details

#key?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/shodan/clients/base.rb', line 21

def key?
  !key.nil?
end