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
-
#call_stack ⇒ Object
readonly
Returns the value of attribute call_stack.
-
#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
- #to_s ⇒ Object
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 :
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 92 def initialize status, reason, ** @call_stack = caller(2) 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
#call_stack ⇒ Object (readonly)
Returns the value of attribute call_stack.
121 122 123 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 121 def call_stack @call_stack end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
123 124 125 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 123 def reason @reason end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
122 123 124 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 122 def status @status end |
Class Method Details
.different(reason, **options) ⇒ Object
116 117 118 119 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 116 def self.different reason, ** return self.new false, reason, ** end |
.return(status, reason, **options) ⇒ Object
106 107 108 109 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 106 def self.return status, reason, ** return self.new status, reason, ** end |
.same(reason = nil, **options) ⇒ Object
111 112 113 114 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 111 def self.same reason = nil, ** return self.new true, reason, ** end |
Instance Method Details
#details ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 135 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}: #{qualifying}" unless .empty? r end |
#different? ⇒ Boolean
125 126 127 128 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 125 def different? !status end |
#same? ⇒ Boolean
130 131 132 133 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 130 def same? status end |
#to_s ⇒ Object
158 159 160 161 162 163 |
# File 'lib/xqsr3/xml/utilities/compare.rb', line 158 def to_s return 'same' if same? "different, because: #{details}" end |