1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-10 21:24:20 +01:00
fab-manager/config/initializers/is_number.rb

12 lines
273 B
Ruby
Raw Normal View History

2016-07-13 18:15:14 +02:00
## 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