Class: Censys::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/censys/document.rb,
lib/censys/document/has_asn.rb,
lib/censys/document/has_location.rb,
lib/censys/document/has_services.rb,
lib/censys/document/has_http_response.rb

Direct Known Subclasses

Certificate, IPv4, Website

Defined Under Namespace

Modules: HasASN, HasHTTPResponse, HasLocation, HasServices

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Document

Initializes the document.

Parameters:

  • attributes (Hash{String => Object})


10
11
12
# File 'lib/censys/document.rb', line 10

def initialize(attributes)
  @attributes = attributes
end

Instance Method Details

#[](name) ⇒ Object

Provides arbitrary access to the attributes

Parameters:

  • name (String)

    The dot-separated field name.

Returns:

  • (Object)


22
23
24
25
# File 'lib/censys/document.rb', line 22

def [](name)
  keys = name.split(".")
  dig(*keys)
end

#dig(*keys) ⇒ Object

Dig attributes

Parameters:

  • keys (Array<String>)

Returns:

  • (Object)


34
35
36
# File 'lib/censys/document.rb', line 34

def dig(*keys)
  @attributes.dig(*keys)
end

#metadataHash{String => Object}

Additional document metadata.

Returns:

  • (Hash{String => Object})


61
62
63
# File 'lib/censys/document.rb', line 61

def 
  @attributes['metadata']
end

#tagsArray<String>

Tags.

Returns:

  • (Array<String>)


43
44
45
# File 'lib/censys/document.rb', line 43

def tags
  @attributes['tags']
end

#updated_atTime

Time last updated at.

Returns:

  • (Time)


52
53
54
# File 'lib/censys/document.rb', line 52

def updated_at
  @updated_at ||= Time.parse(@attributes['updated_at'])
end