Class: Yast::Ops::ListComparator Deprecated
- Inherits:
-
Object
- Object
- Yast::Ops::ListComparator
- Includes:
- Comparable
- Defined in:
- src/ruby/yast/ops.rb
Overview
Deprecated.
array usually don't need comparing
Implements ycp compatible comparison of lists. Difference is only that it use GenericComparator for each of its element.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(value, localized = false) ⇒ ListComparator
constructor
A new instance of ListComparator.
Constructor Details
#initialize(value, localized = false) ⇒ ListComparator
Returns a new instance of ListComparator.
436 437 438 439 |
# File 'src/ruby/yast/ops.rb', line 436 def initialize(value, localized = false) @value = value @localized = localized end |
Instance Method Details
#<=>(other) ⇒ Object
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'src/ruby/yast/ops.rb', line 441 def <=>(other) min_size = [@value.size, other.size].min 0.upto(min_size - 1) do |i| # stupid nil handling fval = @value[i] sval = other[i] return 1 if sval.nil? && !fval.nil? # we need to use out builtin, but also we need to res = Ops.comparable_object(fval, @localized) <=> sval return res if res != 0 end # no decision yet @value.size <=> other.size end |