Sha256: 15c8ca661cef975c61b3d6b115d10968eb74709c0b0b16f1e873b70008ab2e1b

Contents?: true

Size: 399 Bytes

Versions: 18

Compression:

Stored size: 399 Bytes

Contents

module Superstore
  module Types
    class IntegerType < BaseType
      REGEX = /\A[-+]?\d+\Z/
      def encode(int)
        raise ArgumentError.new("#{int.inspect} is not an Integer.") unless int.kind_of?(Integer)
        int.to_s
      end

      def decode(str)
        return nil if str.empty?
        str.to_i
      end

      def typecast(value)
        value.to_i
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
superstore-1.2.0 lib/superstore/types/integer_type.rb
superstore-1.1.4 lib/superstore/types/integer_type.rb
superstore-1.1.3 lib/superstore/types/integer_type.rb
superstore-1.1.2 lib/superstore/types/integer_type.rb
superstore-1.1.1 lib/superstore/types/integer_type.rb
superstore-1.1.0 lib/superstore/types/integer_type.rb
superstore-1.0.12 lib/superstore/types/integer_type.rb
superstore-1.0.11 lib/superstore/types/integer_type.rb
superstore-1.0.10 lib/superstore/types/integer_type.rb
superstore-1.0.9 lib/superstore/types/integer_type.rb
superstore-1.0.8 lib/superstore/types/integer_type.rb
superstore-1.0.7 lib/superstore/types/integer_type.rb
superstore-1.0.6 lib/superstore/types/integer_type.rb
superstore-1.0.5 lib/superstore/types/integer_type.rb
superstore-1.0.4 lib/superstore/types/integer_type.rb
superstore-1.0.3 lib/superstore/types/integer_type.rb
superstore-1.0.2 lib/superstore/types/integer_type.rb
superstore-1.0.0 lib/superstore/types/integer_type.rb