Sha256: 8502b87dffccab74c967d95650495eb08aa9b84d590ee25fc8bfe339c982fe1b

Contents?: true

Size: 507 Bytes

Versions: 4

Compression:

Stored size: 507 Bytes

Contents

module Neows
  module Attributes
    class SanitizedInteger < Virtus::Attribute
      # Coerces a string with commas to an Integer
      #
      # @param value [String]
      # @return [Integer]
      def coerce(value)
        value.delete(',').to_i
      end
    end

    class SanitizedFloat < Virtus::Attribute
      # Coerces a string with commas to a Float
      #
      # @param value [String]
      # @return [Float]
      def coerce(value)
        value.delete(',').to_f
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
neows-1.1.0 lib/neows/attributes.rb
neows-1.0.0 lib/neows/attributes.rb
neows-0.0.2 lib/neows/attributes.rb
neows-0.0.1 lib/neows/attributes.rb