Sha256: 2502c2ec0c48fa2df9b3ba7e20be95c280781bf4b81bae7d7db43cae079c4de4

Contents?: true

Size: 810 Bytes

Versions: 7

Compression:

Stored size: 810 Bytes

Contents

module SoberSwag
  module Reporting
    module Input
      module Converting
        ##
        # Try to convert a boolean-like value to an actual boolean.
        Bool = # rubocop:disable Naming/ConstantName
          (SoberSwag::Reporting::Input::Bool.new |
           (
             SoberSwag::Reporting::Input::Text
              .new
              .enum(*(%w[y yes true t].flat_map { |x| [x, x.upcase] } + ['1'])) |
              SoberSwag::Reporting::Input::Number.new.enum(1)).mapped { |_| true } |
            (
              SoberSwag::Reporting::Input::Text
                .new
                .enum(*(%w[false no n f].flat_map { |x| [x, x.upcase] } + ['0'])) |
              SoberSwag::Reporting::Input::Number.new.enum(0)
            ).mapped { |_| false }
          )
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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