Sha256: ca097c9b2d93fea5f2aba53dd2bb38a87ea8d3bd01718a20cca4815602035a52

Contents?: true

Size: 767 Bytes

Versions: 5

Compression:

Stored size: 767 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

5 entries across 5 versions & 1 rubygems

Version Path
sober_swag-0.25.0 lib/sober_swag/reporting/input/converting/decimal.rb
sober_swag-0.24.1 lib/sober_swag/reporting/input/converting/decimal.rb
sober_swag-0.24.0 lib/sober_swag/reporting/input/converting/decimal.rb
sober_swag-0.23.0 lib/sober_swag/reporting/input/converting/decimal.rb
sober_swag-0.22.0 lib/sober_swag/reporting/input/converting/decimal.rb