Skip to content
Snippets Groups Projects
Commit 0d4f241d authored by Jack Nagel's avatar Jack Nagel
Browse files

Remove explicit type check

parent 02cb05f2
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,10 @@ class Version ...@@ -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 ...@@ -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 ...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment