Class: AbideDevUtils::XCCDF::Parser::Objects::Value

Inherits:
ElementWithId show all
Defined in:
lib/abide_dev_utils/xccdf/parser/objects.rb

Overview

Class for XCCDF Value

Constant Summary

Constants inherited from ElementBase

ElementBase::UNICODE_SYMBOLS

Instance Attribute Summary

Attributes inherited from ElementWithId

#id

Attributes inherited from ElementBase

#child_labels, #children, #link_labels, #links, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ElementBase

#add_link, #add_links, #all_values, #ancestors, #depth, #descendants, #find_similarity, #inspect, #label, #leaf?, #print_tree, #root, #root?, #siblings, #xccdf_type, xmlns

Methods included from Helpers::XPath

#find_element

Methods included from DiffableObject

#check_diffable!, #correlate_added_removed, #diff, #diff_ambiguous, #diff_array_obj, #diff_benchmark, #diff_change_result, #diff_check, #diff_complex_check, #diff_group, #diff_plain_obj, #diff_profile, #diff_rule, #diff_str_obj, #diff_value, #diff_xccdf_select, #process_details_hash!, #result_from_details_hash

Constructor Details

#initialize(element, parent_node: nil) ⇒ Value

Returns a new instance of Value.



832
833
834
835
836
837
838
839
# File 'lib/abide_dev_utils/xccdf/parser/objects.rb', line 832

def initialize(element, parent_node: nil)
  super
  add_child(AttributeValue, element, 'operator')
  add_child(AttributeValue, element, 'type')
  add_child(Title, element)
  add_child(Description, element)
  add_child(ShortText, find_element.at_xpath(element, 'value'))
end

Class Method Details

.xpathObject



865
866
867
# File 'lib/abide_dev_utils/xccdf/parser/objects.rb', line 865

def self.xpath
  'Value'
end

Instance Method Details

#<=>(other) ⇒ Object



841
842
843
844
845
# File 'lib/abide_dev_utils/xccdf/parser/objects.rb', line 841

def <=>(other)
  return nil unless other.instance_of?(self.class)

  title.to_s <=> other.title.to_s
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


847
848
849
850
851
852
853
# File 'lib/abide_dev_utils/xccdf/parser/objects.rb', line 847

def eql?(other)
  operator.value == other.operator.value &&
    type.value == other.type.value &&
    title.to_s == other.title.to_s &&
    description.to_s == other.description.to_s &&
    text == other.text
end

#hashObject



855
856
857
858
859
860
861
862
863
# File 'lib/abide_dev_utils/xccdf/parser/objects.rb', line 855

def hash
  [
    operator.value,
    type.value,
    title.to_s,
    description.to_s,
    text,
  ].join.hash
end

#to_sObject



869
870
871
# File 'lib/abide_dev_utils/xccdf/parser/objects.rb', line 869

def to_s
  "#{title}: #{type.value} #{operator.value} #{text}"
end