Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/toylang/monkey_patching/string.rb
Instance Method Summary collapse
Instance Method Details
#numeric_string? ⇒ Boolean
4 5 6 7 8 |
# File 'lib/toylang/monkey_patching/string.rb', line 4 def numeric_string? !Float(self).nil? rescue StandardError false end |
#to_numeric ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/toylang/monkey_patching/string.rb', line 10 def to_numeric return unless numeric_string? if index('.') to_f else to_i end end |