Class: VerifIP::WHOISResponse
- Inherits:
-
Object
- Object
- VerifIP::WHOISResponse
- Defined in:
- lib/verifip/models.rb
Overview
Response from a WHOIS lookup.
Constant Summary collapse
- FIELDS =
%i[ request_id ip network_cidr network_name org_name abuse_contact rir allocation_date country_code asn asn_org ].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ WHOISResponse
constructor
A new instance of WHOISResponse.
- #inspect ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ WHOISResponse
Returns a new instance of WHOISResponse.
259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/verifip/models.rb', line 259 def initialize(**kwargs) @request_id = kwargs.fetch(:request_id, "") @ip = kwargs.fetch(:ip, "") @network_cidr = kwargs.fetch(:network_cidr, "") @network_name = kwargs.fetch(:network_name, "") @org_name = kwargs.fetch(:org_name, "") @abuse_contact = kwargs.fetch(:abuse_contact, "") @rir = kwargs.fetch(:rir, "") @allocation_date = kwargs.fetch(:allocation_date, "") @country_code = kwargs.fetch(:country_code, "") @asn = kwargs.fetch(:asn, 0) @asn_org = kwargs.fetch(:asn_org, "") end |
Class Method Details
.from_hash(hash) ⇒ Object
273 274 275 276 |
# File 'lib/verifip/models.rb', line 273 def self.from_hash(hash) hash = _symbolize(hash) new(**hash.slice(*FIELDS)) end |
Instance Method Details
#inspect ⇒ Object
283 |
# File 'lib/verifip/models.rb', line 283 def inspect = to_s |
#to_h ⇒ Object
278 279 280 |
# File 'lib/verifip/models.rb', line 278 def to_h FIELDS.each_with_object({}) { |f, h| h[f] = send(f) } end |
#to_s ⇒ Object
282 |
# File 'lib/verifip/models.rb', line 282 def to_s = "WHOISResponse(ip=#{@ip}, network_cidr=#{@network_cidr})" |