Sha256: bc5be2cc2fc47641754b5ae555ba3f0b3eba7285498d629e4ad1d7c1ed47a135
Contents?: true
Size: 498 Bytes
Versions: 3
Compression:
Stored size: 498 Bytes
Contents
module OptParseValidator # Implementation of the Boolean Option class OptBoolean < OptBase TRUE_PATTERN = /\A(true|t|yes|y|1)\z/i FALSE_PATTERN = /\A(false|f|no|n|0)\z/i # @return [ Boolean ] def validate(value) value = value.to_s if value.match(TRUE_PATTERN) return true elsif value.match(FALSE_PATTERN) return false else fail Error, 'Invalid boolean value, expected true|t|yes|y|1|false|f|no|n|0' end end end end
Version data entries
3 entries across 3 versions & 1 rubygems