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.
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
22 23 24 25 |
# File 'lib/censys/document.rb', line 22 def [](name) keys = name.split(".") dig(*keys) end |
#dig(*keys) ⇒ Object
Dig attributes
34 35 36 |
# File 'lib/censys/document.rb', line 34 def dig(*keys) @attributes.dig(*keys) end |
#metadata ⇒ Hash{String => Object}
Additional document metadata.
61 62 63 |
# File 'lib/censys/document.rb', line 61 def @attributes['metadata'] end |
#tags ⇒ Array<String>
Tags.
43 44 45 |
# File 'lib/censys/document.rb', line 43 def @attributes['tags'] end |
#updated_at ⇒ Time
Time last updated at.
52 53 54 |
# File 'lib/censys/document.rb', line 52 def updated_at @updated_at ||= Time.parse(@attributes['updated_at']) end |