Class: Arin::RWS::Client
- Inherits:
-
Object
- Object
- Arin::RWS::Client
- Defined in:
- lib/arin-rws/client.rb
Class Method Summary collapse
Instance Method Summary collapse
- #find_asn(asn) ⇒ Object
- #find_cidr(cidr) ⇒ Object
- #find_ip(ip) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
13 14 |
# File 'lib/arin-rws/client.rb', line 13 def initialize end |
Class Method Details
.init_http ⇒ Object
7 8 9 10 |
# File 'lib/arin-rws/client.rb', line 7 def self.init_http @@http = Net::HTTP.start(Arin::RWS::HOST, Arin::RWS::PORT) @@http.read_timeout=10 end |
.query(resource) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/arin-rws/client.rb', line 16 def self.query(resource) tries = 5 begin r = @@http.get("#{Arin::RWS::BASE_PATH}/#{resource}") result = JSON.parse(r.body) result rescue EOFError, Errno::ECONNRESET if (tries -= 1) > 0 self.init_http retry end end end |
Instance Method Details
#find_asn(asn) ⇒ Object
40 41 42 |
# File 'lib/arin-rws/client.rb', line 40 def find_asn(asn) r = Client::query("asn/#{asn}.json") end |