1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-16 01:24:03 +01:00
fab-manager/config/initializers/is_number.rb
2016-07-13 18:15:14 +02:00

12 lines
273 B
Ruby

## Helper method: will return true if the current string
## can be parsed as a number (float or integer), false otherwise
# exemples:
# "2" => true
# "4.5" => true
# "hello" => false
# "" => false
class String
def is_number?
true if Float(self) rescue false
end
end