Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/rackjson/extensions/core/string.rb
Instance Method Summary collapse
Instance Method Details
#numeric? ⇒ Boolean
2 3 4 |
# File 'lib/rackjson/extensions/core/string.rb', line 2 def numeric? true if Float(self) rescue false end |
#to_number ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/rackjson/extensions/core/string.rb', line 6 def to_number if numeric? f = to_f i = to_i f == i ? i : f end end |