lib/versionaire/version.rb in versionaire-9.4.0 vs lib/versionaire/version.rb in versionaire-10.0.0
- old
+ new
@@ -32,27 +32,19 @@
def []= key, value
super(key, value).tap { validate }
end
- def + other
- revalue(other.to_h) { |previous, current| previous + current }
- end
+ def +(other) = revalue(other.to_h) { |previous, current| previous + current }
- def - other
- revalue(other.to_h) { |previous, current| previous - current }
- end
+ def -(other) = revalue(other.to_h) { |previous, current| previous - current }
- def == other
- hash == other.hash
- end
+ def ==(other) = hash == other.hash
alias_method :eql?, :==
- def <=> other
- to_s <=> other.to_s
- end
+ def <=>(other) = to_s <=> other.to_s
def down(key, value = 1) = revalue(key => value) { |previous, current| previous - current }
def up(key, value = 1) = revalue(key => value) { |previous, current| previous + current }
@@ -62,10 +54,13 @@
alias_method :values, :to_a
private
def validate
- fail Errors::InvalidNumber if to_a.any? { |number| !number.is_a? Integer }
- fail Errors::NegativeNumber if to_a.any?(&:negative?)
+ fail Error, "Major, minor, and patch must be a number." if to_a.any? do |number|
+ !number.is_a? Integer
+ end
+
+ fail Error, "Major, minor, and patch must be a positive number." if to_a.any?(&:negative?)
end
end
end