class CvssSuite::CvssProperty
This class represents a CVSS property of a CVSS metric.
Public Class Methods
new(property)
click to toggle source
Creates a new CVSS property by a property
.
Property
needs to consist of a name, a abbreviation, the possible positions in the CVSS vector, a weight, and the available values for the property.
# File lib/cvss_suite/cvss_property.rb, line 22 def initialize(property) @property = property @property[:default_value] ||= 'Not Available' end
Public Instance Methods
abbreviation()
click to toggle source
Returns the abbreviation of the property.
# File lib/cvss_suite/cvss_property.rb, line 37 def abbreviation @property[:abbreviation] end
name()
click to toggle source
Returns the full name of the property.
# File lib/cvss_suite/cvss_property.rb, line 30 def name @property[:name] end
position()
click to toggle source
Returns the possible positions in the CVSS vector of the property.
# File lib/cvss_suite/cvss_property.rb, line 51 def position @property[:position] end
score()
click to toggle source
Returns the score of the selected value.
# File lib/cvss_suite/cvss_property.rb, line 72 def score @selected_value[:weight] end
selected_value()
click to toggle source
Returns the selected value of the property.
# File lib/cvss_suite/cvss_property.rb, line 58 def selected_value @selected_value || @property[:default_value] end
set_selected_value(selected_value)
click to toggle source
Sets the selected value by a value
.
# File lib/cvss_suite/cvss_property.rb, line 79 def set_selected_value(selected_value) values.each do |value| value[:selected] = selected_value.eql?(value[:abbreviation]) end @selected_value = values.detect { |value| value[:selected] } end
valid?()
click to toggle source
Returns true if the property is valid.
# File lib/cvss_suite/cvss_property.rb, line 65 def valid? !@selected_value.nil? end
values()
click to toggle source
Returns all available values of the property.
# File lib/cvss_suite/cvss_property.rb, line 44 def values @property[:values] end