Class: Sigstore::TUF::Timestamp
- Inherits:
-
Object
- Object
- Sigstore::TUF::Timestamp
- Defined in:
- lib/sigstore/tuf/timestamp.rb
Constant Summary collapse
- TYPE =
"timestamp"
Instance Attribute Summary collapse
-
#expires ⇒ Object
readonly
Returns the value of attribute expires.
-
#snapshot_meta ⇒ Object
readonly
Returns the value of attribute snapshot_meta.
-
#spec_version ⇒ Object
readonly
Returns the value of attribute spec_version.
-
#unrecognized_fields ⇒ Object
readonly
Returns the value of attribute unrecognized_fields.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #expired?(reference_time) ⇒ Boolean
-
#initialize(data) ⇒ Timestamp
constructor
A new instance of Timestamp.
Constructor Details
#initialize(data) ⇒ Timestamp
Returns a new instance of Timestamp.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sigstore/tuf/timestamp.rb', line 23 def initialize(data) type = data.fetch("_type") raise Error::InvalidData, "Expected type to be #{TYPE}, got #{type.inspect}" unless type == TYPE @version = data.fetch("version") @spec_version = data.fetch("spec_version") @expires = Time.iso8601 data.fetch("expires") = data.fetch("meta") = Snapshot::Meta.from_hash(["snapshot.json"]) @unrecognized_fields = data.fetch("unrecognized_fields", {}) end |
Instance Attribute Details
#expires ⇒ Object (readonly)
Returns the value of attribute expires.
21 22 23 |
# File 'lib/sigstore/tuf/timestamp.rb', line 21 def expires @expires end |
#snapshot_meta ⇒ Object (readonly)
Returns the value of attribute snapshot_meta.
21 22 23 |
# File 'lib/sigstore/tuf/timestamp.rb', line 21 def end |
#spec_version ⇒ Object (readonly)
Returns the value of attribute spec_version.
21 22 23 |
# File 'lib/sigstore/tuf/timestamp.rb', line 21 def spec_version @spec_version end |
#unrecognized_fields ⇒ Object (readonly)
Returns the value of attribute unrecognized_fields.
21 22 23 |
# File 'lib/sigstore/tuf/timestamp.rb', line 21 def unrecognized_fields @unrecognized_fields end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
21 22 23 |
# File 'lib/sigstore/tuf/timestamp.rb', line 21 def version @version end |
Instance Method Details
#expired?(reference_time) ⇒ Boolean
35 36 37 |
# File 'lib/sigstore/tuf/timestamp.rb', line 35 def expired?(reference_time) @expires < reference_time end |