Permalink
Browse files

added decimal normalization to measurement tokens

  • Loading branch information...
1 parent d9340b6 commit 6a5a80019a1617ab0d96fe816f938c9fb807168f evan wheeler committed Jan 12, 2009
Showing with 7 additions and 7 deletions.
  1. +1 −1 lib/fuzz.rb
  2. +2 −2 lib/fuzz/token/height.rb
  3. +2 −2 lib/fuzz/token/length.rb
  4. +2 −2 lib/fuzz/token/weight.rb
View
@@ -11,7 +11,7 @@ module Fuzz
# The regex chunk which is considered a valid
# delimiter between tokens in a form submission.
- Delimiter = '\A|[\s;,]+|' + Replacement + '|\Z'
+ Delimiter = '\A|[\s;,\*]+|' + Replacement + '|\Z'
end
View
@@ -9,8 +9,8 @@ class Height < Base
# convert captured digits
# into a float object
- def normalize(height_str)
- height_str.to_f
+ def normalize(height_str, decimal_str=nil)
+ decimal_str.nil? ? height_str.to_f : (height_str + decimal_str).to_f
end
def humanize(height_f)
View
@@ -7,8 +7,8 @@ class Length < Base
# convert captured digits
# into a float object
- def normalize(length_str)
- length_str.to_f
+ def normalize(length_str, decimal_str=nil)
+ decimal_str.nil? ? length_str.to_f : (length_str + decimal_str).to_f
end
def humanize(length_f)
View
@@ -13,8 +13,8 @@ class Weight < Base
# convert captured digits
# into a float object
- def normalize(weight_str)
- weight_str.to_f
+ def normalize(weight_str, decimal_str=nil)
+ decimal_str.nil? ? weight_str.to_f : (weight_str + decimal_str).to_f
end
def humanize(weight_f)

0 comments on commit 6a5a800

Please sign in to comment.