Sha256: c06fdffe015fb7f98c63841958a31587a1d7f8bfa6c23cf8badb479f8dd98fe7

Contents?: true

Size: 769 Bytes

Versions: 2

Compression:

Stored size: 769 Bytes

Contents

module SoberSwag
  module Reporting
    module Input
      module Converting
        ##
        # Parse a decimal.
        Decimal =
          (SoberSwag::Reporting::Input::Number.new.mapped(&:to_d).format(:decimal) |
          SoberSwag::Reporting::Input::Text
          .new
          .format('decimal')
          .mapped do |v|
            BigDecimal(v)
          rescue ArgumentError
            Report::Value.new(['was not a decimal'])
          end).described(<<~MARKDOWN).referenced('SoberSwag.Converting.Decimal')
            Decimal formatted input.
            Will either convert a JSON number to a decimal, or accept a string representation.
            The string representation allows for greater precision.
          MARKDOWN
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sober_swag-0.25.2 lib/sober_swag/reporting/input/converting/decimal.rb
sober_swag-0.25.1 lib/sober_swag/reporting/input/converting/decimal.rb