Class: CVESchema::CVE::Timeline

Inherits:
Object
  • Object
show all
Includes:
HasLangValue
Defined in:
lib/cve_schema/cve/timeline.rb

Overview

Represents a timeline entry in the "timeline" JSON Array.

Instance Attribute Summary collapse

Attributes included from HasLangValue

#lang, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasLangValue

included, #to_s

Constructor Details

#initialize(time:, **kargs) ⇒ Timeline

Initializes the timeline object.

Parameters:

  • time (DateTime)


23
24
25
26
27
# File 'lib/cve_schema/cve/timeline.rb', line 23

def initialize(time: , **kargs)
  super(**kargs)

  @time = time
end

Instance Attribute Details

#timeDateTime (readonly)

The time of the timeline event.

Returns:

  • (DateTime)


16
17
18
# File 'lib/cve_schema/cve/timeline.rb', line 16

def time
  @time
end

Class Method Details

.from_json(json) ⇒ Hash{Symbol => Object}

Maps the parsed JSON to a Symbol Hash for #initialize.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:

  • (Hash{Symbol => Object})

    The mapped Symbol Hash.



40
41
42
43
44
45
46
# File 'lib/cve_schema/cve/timeline.rb', line 40

def self.from_json(json)
  {
    lang: json['lang'],
    time: Timestamp.parse(json['time']),
    value: json['value']
  }
end

.load(json) ⇒ Timeline

Loads the timeline object from the parsed JSON.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:

  • (Timeline)

    The loaded timeline object.



59
60
61
# File 'lib/cve_schema/cve/timeline.rb', line 59

def self.load(json)
  new(**from_json(json))
end