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