lib/jss/ruby_extensions/string/predicates.rb in ruby-jss-1.2.6 vs lib/jss/ruby_extensions/string/predicates.rb in ruby-jss-1.2.9

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright 2019 Pixar +# Copyright 2020 Pixar # # Licensed under the Apache License, Version 2.0 (the "Apache License") # with the following modification; you may not use this file except in # compliance with the Apache License and the following modification to it: @@ -27,18 +27,28 @@ module String module Predicates - INTEGER_RE = /\A[0-9]+\Z/.freeze + INTEGER_RE = /\A-?[0-9]+\Z/.freeze + FLOAT_RE = /\A-?[0-9]+\.[0-9]+\Z/.freeze - # Is this string also a positive integer? - # (i.e. it consists only of numberic digits) + # Is this string also an integer? + # (i.e. it consists only of numberic digits, maybe with a dash in front) # # @return [Boolean] # def jss_integer? self =~ INTEGER_RE ? true : false + end + + # Is this string also a floar? + # (i.e. it consists only of numberic digits) + # + # @return [Boolean] + # + def jss_float? + self =~ FLOAT_RE ? true : false end end # module end # module