lib/sugarcube-numbers/nsstring.rb in sugarcube-1.5.4 vs lib/sugarcube-numbers/nsstring.rb in sugarcube-1.5.5
- old
+ new
@@ -1,13 +1,17 @@
class NSString
# @return boolean
- def nan?
- self.to_number.nil?
+ def nan?(style=NSNumberFormatterDecimalStyle)
+ self.to_number(style).nil?
end
- def to_number
+ def to_number(style=NSNumberFormatterDecimalStyle)
+ if style.respond_to?(:nsnumberstyle)
+ style = style.nsnumberstyle
+ end
number_formatter = NSNumberFormatter.new
+ number_formatter.numberStyle = style
number_formatter.numberFromString(self)
end
end