Class: CVESchema::CVE::Impact::CVSSv2

Inherits:
Object
  • Object
show all
Defined in:
lib/cve_schema/cve/impact/cvss_v2.rb

Defined Under Namespace

Classes: BM, EM, TM

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bm: nil, tm: nil, em: nil) ⇒ CVSSv2

Initializes the CVSSv2.

Parameters:

  • bm (BM, nil) (defaults to: nil)
  • tm (TM, nil) (defaults to: nil)
  • em (EM, nil) (defaults to: nil)


279
280
281
282
283
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 279

def initialize(bm: nil, tm: nil, em: nil)
  @bm = bm
  @tm = tm
  @em = em
end

Instance Attribute Details

#bmBM? (readonly)

Returns:

  • (BM, nil)


105
106
107
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 105

def bm
  @bm
end

#emEM? (readonly)

Returns:

  • (EM, nil)


268
269
270
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 268

def em
  @em
end

#tmTM? (readonly)

The Temporal Metrics Group.

Returns:

  • (TM, nil)


179
180
181
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 179

def tm
  @tm
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.



294
295
296
297
298
299
300
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 294

def self.from_json(json)
  {
    bm: json['BM'] && BM.load(json['BM']),
    tm: json['TM'] && TM.load(json['TM']),
    em: json['EM'] && EM.load(json['EM']),
  }
end

.load(json) ⇒ self

Loads the CVSSv2 object from the parsed JSON.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:

  • (self)

    The loaded CVSSv2 object.



311
312
313
# File 'lib/cve_schema/cve/impact/cvss_v2.rb', line 311

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