Sha256: 7a8784945cdfde4cf9b628ecf9041868465fecd12e935ed821026b2cffb40a4d
Contents?: true
Size: 452 Bytes
Versions: 7
Compression:
Stored size: 452 Bytes
Contents
module Kernel def Boolean(string) return true if string == true || string =~ /^true$/i || string == "1" || string == 1 || string.to_s.downcase == "yes" return false if string == false || string.nil? || string =~ /^false$/i || string == "0" || string == 0 || string.to_s.downcase == "no" || string.blank? raise ArgumentError.new("invalid value for Boolean: \"#{string}\"") end end class Object def to_bool Boolean(self) end end
Version data entries
7 entries across 7 versions & 1 rubygems