Class: Sigstore::TUF::Snapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/sigstore/tuf/snapshot.rb

Overview

The class for the Snapshot role

Defined Under Namespace

Classes: Meta

Constant Summary collapse

TYPE =
"snapshot"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Snapshot

Returns a new instance of Snapshot.

Raises:



26
27
28
29
30
31
32
33
# File 'lib/sigstore/tuf/snapshot.rb', line 26

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")
  @expires = Time.iso8601 data.fetch("expires")
  @meta = data.fetch("meta").transform_values { Meta.from_hash(_1) }
end

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



24
25
26
# File 'lib/sigstore/tuf/snapshot.rb', line 24

def meta
  @meta
end

#versionObject (readonly)

Returns the value of attribute version.



24
25
26
# File 'lib/sigstore/tuf/snapshot.rb', line 24

def version
  @version
end

Instance Method Details

#expired?(reference_time) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/sigstore/tuf/snapshot.rb', line 35

def expired?(reference_time)
  @expires < reference_time
end