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
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
......
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