Sha256: 80fbd4c00adb8208abcdeee6b4ac456a7c12988d3a52612248dc0708e372dde5

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

# CVSS-Suite, a Ruby gem to manage the CVSS vector
#
# Copyright (c) Siemens AG, 2016
#
# Authors:
#   Oliver Hambörger <oliver.hamboerger@siemens.com>
#
# This work is licensed under the terms of the MIT license.
# See the LICENSE.md file in the top-level directory.

##
# This class represents any CVSS metric.

class CvssMetric

  ##
  # Creates a new CVSS metric by +properties+

  def initialize(selected_properties)
    @properties = []
    init_properties
    extract_selected_choices_from selected_properties
  end

  ##
  # Returns if the metric is valid.

  def valid?
    @properties.each do |property|
      return false unless property.valid?
    end
    true
  end

  ##
  # Returns number of properties for this metric.

  def count
    @properties.count
  end

  private

  def extract_selected_choices_from(selected_properties)
    selected_properties.each do |selected_property|
      property = @properties.detect {
          |p| p.abbreviation == selected_property[:name] && p.position.include?(selected_property[:position])
      }
      property.set_selected_choice selected_property[:selected] unless property.nil?
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cvss-suite-1.2.0 lib/cvss_suite/cvss_metric.rb
cvss-suite-1.1.2 lib/cvss_suite/cvss_metric.rb
cvss-suite-1.1.1 lib/cvss_suite/cvss_metric.rb
cvss-suite-1.1.0 lib/cvss_suite/cvss_metric.rb
cvss-suite-1.0.8 lib/cvss_suite/cvss_metric.rb