Sha256: f11b2d470381c4bafd10bf6305c531cf18d6901dad6e8c5e33866d448f9cff8b

Contents?: true

Size: 867 Bytes

Versions: 7

Compression:

Stored size: 867 Bytes

Contents

module SoberSwag
  module Reporting
    module Input
      ##
      # Input for a single text value.
      class Text < Base
        def call(value)
          return value if value.is_a?(String)

          Report::Value.new(['was not a string'])
        end

        ##
        # Get a new input value which requires a regexp.
        #
        # @paran regexp [Regexp] regular expression to match on
        # @return [Pattern] pattern-based input.
        def with_pattern(regexp)
          Pattern.new(self, regexp)
        end

        include Comparable

        def eql?(other)
          other.class == self.class
        end

        def <=>(other)
          eql?(other) ? 0 : 1
        end

        def hash
          [self.class.hash, 1].hash
        end

        def swagger_schema
          [{ type: 'string' }, {}]
        end
      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/text.rb
sober_swag-0.25.1 lib/sober_swag/reporting/input/text.rb
sober_swag-0.25.0 lib/sober_swag/reporting/input/text.rb
sober_swag-0.24.1 lib/sober_swag/reporting/input/text.rb
sober_swag-0.24.0 lib/sober_swag/reporting/input/text.rb
sober_swag-0.23.0 lib/sober_swag/reporting/input/text.rb
sober_swag-0.22.0 lib/sober_swag/reporting/input/text.rb