Class: Censys::Document
- Inherits:
-
Object
- Object
- Censys::Document
- 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
Defined Under Namespace
Modules: HasASN, HasHTTPResponse, HasLocation, HasServices
Instance Method Summary collapse
-
#[](name) ⇒ Object
Provides arbitrary access to the attributes.
-
#dig(*keys) ⇒ Object
Dig attributes.
-
#initialize(attributes) ⇒ Document
constructor
Initializes the document.
-
#metadata ⇒ Hash{String => Object}
Additional document metadata.
-
#tags ⇒ Array<String>
Tags.
-
#updated_at ⇒ Time
Time last updated at.
Constructor Details
#initialize(attributes) ⇒ Document
Initializes the document.
8 9 10 |
# File 'lib/censys/document.rb', line 8 def initialize(attributes) @attributes = attributes end |
Instance Method Details
#[](name) ⇒ Object
Provides arbitrary access to the attributes
20 21 22 23 |
# File 'lib/censys/document.rb', line 20 def [](name) keys = name.split(".") dig(*keys) end |
#dig(*keys) ⇒ Object
Dig attributes
32 33 34 |
# File 'lib/censys/document.rb', line 32 def dig(*keys) @attributes.dig(*keys) end |
#metadata ⇒ Hash{String => Object}
Additional document metadata.
59 60 61 |
# File 'lib/censys/document.rb', line 59 def @attributes['metadata'] end |
#tags ⇒ Array<String>
Tags.
41 42 43 |
# File 'lib/censys/document.rb', line 41 def @attributes['tags'] end |
#updated_at ⇒ Time
Time last updated at.
50 51 52 |
# File 'lib/censys/document.rb', line 50 def updated_at @updated_at ||= Time.parse(@attributes['updated_at']) end |