Remove explicit type check
This commit is contained in:
parent
02cb05f22b
commit
0d4f241d48
@ -17,6 +17,10 @@ class Version
|
|||||||
def to_s
|
def to_s
|
||||||
value.to_s
|
value.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def numeric?
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class NullToken < Token
|
class NullToken < Token
|
||||||
@ -76,6 +80,10 @@ class Version
|
|||||||
-Integer(other <=> self)
|
-Integer(other <=> self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def numeric?
|
||||||
|
true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class CompositeToken < StringToken
|
class CompositeToken < StringToken
|
||||||
@ -208,12 +216,12 @@ class Version
|
|||||||
protected
|
protected
|
||||||
|
|
||||||
def begins_with_numeric?
|
def begins_with_numeric?
|
||||||
NumericToken === tokens.first
|
tokens.first.numeric?
|
||||||
end
|
end
|
||||||
|
|
||||||
def pad_to(length)
|
def pad_to(length)
|
||||||
if begins_with_numeric?
|
if begins_with_numeric?
|
||||||
nums, rest = tokens.partition { |t| NumericToken === t }
|
nums, rest = tokens.partition(&:numeric?)
|
||||||
nums.fill(NULL_TOKEN, nums.length, length - tokens.length)
|
nums.fill(NULL_TOKEN, nums.length, length - tokens.length)
|
||||||
nums.concat(rest)
|
nums.concat(rest)
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user