Sha256: 888ba8cc40ed5cb22c16478a81c8b5ec4495bb65397b0d113d560002d851885e

Contents?: true

Size: 390 Bytes

Versions: 1

Compression:

Stored size: 390 Bytes

Contents

module Swagger
  class Boolean
    TRUE_REGEXP = /(y|Y|yes|Yes|YES|true|True|TRUE|on|On|ON)/
    FALSE_REGEXP = /(n|N|no|No|NO|false|False|FALSE|off|Off|OFF)/

    def self.coerce(obj)
      val = obj.to_s.downcase
      return true if val.match(TRUE_REGEXP)
      return false if val.match(FALSE_REGEXP)
      raise ArgumentError, "#{obj} cannot be coerced to a boolean"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
swagger-core-0.3.0 lib/swagger/boolean.rb