Class: AbideDevUtils::XCCDF::Diff::NumberTitleContainer
- Inherits:
-
Object
- Object
- AbideDevUtils::XCCDF::Diff::NumberTitleContainer
- Includes:
- Comparable
- Defined in:
- lib/abide_dev_utils/xccdf/diff/benchmark/number_title.rb
Overview
Holds a number and title for a child of a benchmark and provides methods to compare it to another child.
Instance Attribute Summary collapse
-
#child ⇒ Object
readonly
Returns the value of attribute child.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#prop_checker ⇒ Object
Returns the value of attribute prop_checker.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #diff(other) ⇒ Object
-
#initialize(child, prop_checker = nil) ⇒ NumberTitleContainer
constructor
A new instance of NumberTitleContainer.
Constructor Details
#initialize(child, prop_checker = nil) ⇒ NumberTitleContainer
Returns a new instance of NumberTitleContainer.
209 210 211 212 213 214 |
# File 'lib/abide_dev_utils/xccdf/diff/benchmark/number_title.rb', line 209 def initialize(child, prop_checker = nil) @child = child @number = child.number.to_s @title = child.title.to_s @prop_checker = prop_checker end |
Instance Attribute Details
#child ⇒ Object (readonly)
Returns the value of attribute child.
207 208 209 |
# File 'lib/abide_dev_utils/xccdf/diff/benchmark/number_title.rb', line 207 def child @child end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
207 208 209 |
# File 'lib/abide_dev_utils/xccdf/diff/benchmark/number_title.rb', line 207 def number @number end |
#prop_checker ⇒ Object
Returns the value of attribute prop_checker.
206 207 208 |
# File 'lib/abide_dev_utils/xccdf/diff/benchmark/number_title.rb', line 206 def prop_checker @prop_checker end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
207 208 209 |
# File 'lib/abide_dev_utils/xccdf/diff/benchmark/number_title.rb', line 207 def title @title end |
Instance Method Details
#<=>(other) ⇒ Object
242 243 244 |
# File 'lib/abide_dev_utils/xccdf/diff/benchmark/number_title.rb', line 242 def <=>(other) child <=> other.child end |
#diff(other) ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/abide_dev_utils/xccdf/diff/benchmark/number_title.rb', line 216 def diff(other) return %i[equal exist] if number == other.number && title == other.title if number == other.number && title != other.title c_diff = correlate_prop_diff_types(@prop_checker.title(other.title), other.prop_checker.title(other.title)) [:title, c_diff] elsif title == other.title && number != other.number c_diff = correlate_prop_diff_types(@prop_checker.number(other.number), other.prop_checker.number(other.number)) [:number, c_diff] else %i[both exist] end rescue StandardError => e err_str = [ 'Error diffing number and title', "Number: #{number}", "Title: #{title}", "Other number: #{other.number}", "Other title: #{other.title}", e., ] raise NumberTitleDiffError, err_str.join(', ') end |