Sha256: 561b49cb7a7a3512a81b221cb0a957462e7ce164b6bc4c0f81e14d65afee3fc3

Contents?: true

Size: 483 Bytes

Versions: 38

Compression:

Stored size: 483 Bytes

Contents

module Foobara
  module BuiltinTypes
    module Integer
      module Casters
        class String < Value::Caster
          INTEGER_REGEX = /^-?\d+$/

          def applicable?(value)
            value.is_a?(::String) && value =~ INTEGER_REGEX
          end

          def applies_message
            "be a string of digits optionally with a minus sign in front"
          end

          def cast(string)
            string.to_i
          end
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
foobara-0.0.38 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.37 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.36 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.35 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.34 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.33 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.32 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.31 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.30 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.29 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.28 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.27 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.26 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.25 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.24 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.23 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.22 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.21 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.20 projects/builtin_types/src/integer/casters/string.rb
foobara-0.0.19 projects/builtin_types/src/integer/casters/string.rb