Sha256: 8df2705a38b1f2adb437a63c097d9a184e208a130f70a9e8484fdc2939e5504f
Contents?: true
Size: 621 Bytes
Versions: 26
Compression:
Stored size: 621 Bytes
Contents
module Foobara module BuiltinTypes module BigDecimal module Casters class String < Value::Caster FLOAT_REGEX = /^-?\d+(\.\d+)?([eE]-?\d+)?$/ def applicable?(value) value.is_a?(::String) && value =~ FLOAT_REGEX end def applies_message "be a string of digits with one decimal point optionally amongst " \ "them and optionally with a minus sign in front and optionally an exponent denoted with e" end def cast(string) BigDecimal(string) end end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems