Class: Xqsr3::XML::Utilities::Compare::Result
- Inherits:
-
Object
- Object
- Xqsr3::XML::Utilities::Compare::Result
- Includes:
- Quality::ParameterChecking
- Defined in:
- lib/xqsr3/xml/utilities/compare.rb
Overview
Class that represents the result of an XML comparison
NOTE: Sadly, we cannot create instances of FalseClass
/TrueClass
, to which we could then add a reason
attribute, so instead we must have a results class
Instance Attribute Summary collapse
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
- .different(reason, **options) ⇒ Object
- .return(status, reason, **options) ⇒ Object
- .same(reason = nil, **options) ⇒ Object
Instance Method Summary collapse
- #details ⇒ Object
- #different? ⇒ Boolean
-
#initialize(status, reason, **options) ⇒ Result
constructor
Options:.
- #same? ⇒ Boolean
Methods included from Quality::ParameterChecking
check_param, check_parameter, included
Constructor Details
#initialize(status, reason, **options) ⇒ Result
Options:
:different_attributes
:different_attribute_count
:different_attribute_order
:different_child_node_count
:different_child_node_order
:different_child_nodes
:different_node_names
:different_node_contents
:parameter_is_empty
:parameter_is_nil
:
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 90 def initialize status, reason, ** check_parameter status, 'status', types: [ ::FalseClass, ::TrueClass ] check_parameter reason, 'reason', type: ::Symbol, allow_nil: true @status = status @reason = reason @lhs_node = [:lhs_node] @rhs_node = [:rhs_node] end |
Instance Attribute Details
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
118 119 120 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 118 def reason @reason end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
117 118 119 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 117 def status @status end |
Class Method Details
.different(reason, **options) ⇒ Object
112 113 114 115 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 112 def self.different reason, ** return self.new false, reason, ** end |
.return(status, reason, **options) ⇒ Object
102 103 104 105 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 102 def self.return status, reason, ** return self.new status, reason, ** end |
.same(reason = nil, **options) ⇒ Object
107 108 109 110 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 107 def self.same reason = nil, ** return self.new true, reason, ** end |
Instance Method Details
#details ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 130 def details r = reason.to_s.gsub /_/, ' ' = '' if @lhs_node += '; ' unless .empty? += "lhs-node=#{@lhs_node}" end if @rhs_node += '; ' unless .empty? += "rhs-node=#{@rhs_node}" end r = "#{r}: #{}" unless .empty? r end |
#different? ⇒ Boolean
120 121 122 123 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 120 def different? !status end |
#same? ⇒ Boolean
125 126 127 128 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 125 def same? status end |