Add support for hexadecimal values for OptInt options

git-svn-id: file:///home/svn/framework3/trunk@4652 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
HD Moore 2007-04-05 05:00:55 +00:00
parent 4dfa1f0b8f
commit 4d3a91f63b
1 changed files with 6 additions and 2 deletions

View File

@ -391,13 +391,17 @@ class OptInt < OptBase
end
def normalize(value)
value.to_i
if (value.to_s.match(/^0x[a-fA-F\d]+$/))
value.to_i(16)
else
value.to_i
end
end
def valid?(value)
return false if empty_required_value?(value)
if value and value.to_s.match(/^\d+$/) == nil
if value and not normalize(value).to_s.match(/^\d+$/)
return false
end