mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-29 10:24:20 +01:00
12 lines
273 B
Ruby
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
|