Class: InstanceVariableComparability
- Inherits:
-
Object
- Object
- InstanceVariableComparability
- Includes:
- Comparable
- Defined in:
- lib/availability/instance_variable_comparability.rb
Direct Known Subclasses
Availability::AbstractAvailability, Availability::Exclusion, Availability::Exclusion::Rule::AfterDate, Availability::Exclusion::Rule::AfterDateAndTime, Availability::Exclusion::Rule::AfterTime, Availability::Exclusion::Rule::BeforeDate, Availability::Exclusion::Rule::BeforeDateAndTime, Availability::Exclusion::Rule::BeforeTime, Availability::Exclusion::Rule::OnDate, Availability::Exclusion::Rule::OnDayOfWeek
Instance Method Summary collapse
Instance Method Details
#<=>(other) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/availability/instance_variable_comparability.rb', line 3 def <=>(other) return 1 if other.nil? comparisons = comparability_ivar_names.map do |ivar| instance_variable_get(ivar) <=> other.instance_variable_get(ivar) end.reject { |c| c == 0 } return 0 if comparisons.empty? comparisons.inject(0) { |acc, each| acc + each } >= 1 ? 1 : -1 end |