Sha256: 772166857817a80e76e2248b00248515c45c327a5a3baef7249024c75350cf6b

Contents?: true

Size: 832 Bytes

Versions: 7

Compression:

Stored size: 832 Bytes

Contents

# frozen_string_literal: true

module Fortnox
  module API
    module Types
      module Sized
        module String
          def self.[](size)
            Types::Strict::String.constrained(max_size: size).optional.constructor do |value|
              value.to_s unless value.nil?
            end
          end
        end

        module Integer
          def self.[](low, high)
            Types::Strict::Int.constrained(gteq: low, lteq: high).optional.constructor do |value|
              value.to_i unless value.nil?
            end
          end
        end

        module Float
          def self.[](low, high)
            Types::Strict::Float.constrained(gteq: low, lteq: high).optional.constructor do |value|
              value.to_f unless value.nil?
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fortnox-api-0.8.0 lib/fortnox/api/types/sized.rb
fortnox-api-0.7.2 lib/fortnox/api/types/sized.rb
fortnox-api-0.7.1 lib/fortnox/api/types/sized.rb
fortnox-api-0.7.0 lib/fortnox/api/types/sized.rb
fortnox-api-0.6.2 lib/fortnox/api/types/sized.rb
fortnox-api-0.6.1 lib/fortnox/api/types/sized.rb
fortnox-api-0.6.0 lib/fortnox/api/types/sized.rb