Module: CVESchema::CVE::HasLangValue::ClassMethods

Defined in:
lib/cve_schema/cve/has_lang_value.rb

Overview

Class methods.

Constant Summary collapse

LANG =
{
  'eng' => :eng, # English
  'es'  => :es, # Spanish
}

Instance Method Summary collapse

Instance Method Details

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

Maps the parsed JSON to a Symbol Hash for CVESchema::CVE::HasLangValue#initialize.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:

  • (Hash{Symbol => Object})

    The mapped Symbol Hash.



38
39
40
41
42
43
# File 'lib/cve_schema/cve/has_lang_value.rb', line 38

def from_json(json)
  {
    lang:  LANG.fetch(json['lang'],json['lang']),
    value: json['value']
  }
end

#load(json) ⇒ HasLangValue

Loads the objects from the parsed JSON.

Parameters:

  • json (Hash{String => Object})

    The parsed JSON.

Returns:



54
55
56
# File 'lib/cve_schema/cve/has_lang_value.rb', line 54

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