Class: VerifIP::BatchResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/verifip/models.rb

Overview

Response from a batch IP check.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(results = []) ⇒ BatchResponse

Returns a new instance of BatchResponse.



71
72
73
# File 'lib/verifip/models.rb', line 71

def initialize(results = [])
  @results = results.freeze
end

Instance Attribute Details

#resultsArray<CheckResponse> (readonly)

Returns:



69
70
71
# File 'lib/verifip/models.rb', line 69

def results
  @results
end

Class Method Details

.from_hash(hash) ⇒ BatchResponse

Build a BatchResponse from a parsed JSON hash.

Parameters:

  • hash (Hash)

    parsed API response with “results” key

Returns:



79
80
81
82
83
84
# File 'lib/verifip/models.rb', line 79

def self.from_hash(hash)
  items = (hash["results"] || hash[:results] || []).map do |r|
    CheckResponse.from_hash(r)
  end
  new(items)
end

Instance Method Details

#inspectObject



89
# File 'lib/verifip/models.rb', line 89

def inspect = to_s

#sizeObject



86
# File 'lib/verifip/models.rb', line 86

def size = @results.size

#to_sObject



88
# File 'lib/verifip/models.rb', line 88

def to_s = "BatchResponse(results=#{size})"