Class: Censys::Report::Response

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/censys/report/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



25
26
27
28
29
30
31
# File 'lib/censys/report/response.rb', line 25

def initialize(response)
  @status  = response['status']
  @results = Hash[response['results'].map { |result|
    [result['key'], result['doc_count']]
  }]
  @metadata = Metadata.new(response['metadata'])
end

Instance Attribute Details

#metadataMetadata (readonly)

Response metadata.

Returns:



23
24
25
# File 'lib/censys/report/response.rb', line 23

def 
  @metadata
end

#resultsHash{String => Fixnum} (readonly)

Response results.

Returns:

  • (Hash{String => Fixnum})


18
19
20
# File 'lib/censys/report/response.rb', line 18

def results
  @results
end

#statusString (readonly)

Response status.

Returns:

  • (String)


13
14
15
# File 'lib/censys/report/response.rb', line 13

def status
  @status
end

Instance Method Details

#each {|key, doc_count| ... } ⇒ Object

Enumerate through all response results.

Yields:

  • (key, doc_count)

Yield Parameters:

  • key (String)
  • doc_count (Fixnum)


51
52
53
# File 'lib/censys/report/response.rb', line 51

def each(&block)
  @results.each(&block)
end

#ok?Boolean

Determines if the response was OK.

Returns:

  • (Boolean)


38
39
40
# File 'lib/censys/report/response.rb', line 38

def ok?
  @status == 'ok'
end