Sha256: 3f4a127ae2d4cb4656383cfba14bef534e0d67af0bdd48041c57a1233243e658
Contents?: true
Size: 983 Bytes
Versions: 58
Compression:
Stored size: 983 Bytes
Contents
# Thank you Rails! class String def camelize(uppercase_first_letter = true) string = to_s if uppercase_first_letter string = string.sub(/^[a-z\d]*/) { $&.capitalize } else string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase } end string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" } string.gsub!('/', '::') string end unless respond_to?(:camelize) end class Integer def base(b) self < b ? [self] : (self/b).base(b) + [self%b] end end begin require 'securerandom' SecureRandom.uuid rescue LoadError, NoMethodError # See http://jira.codehaus.org/browse/JRUBY-6176 module SecureRandom def self.uuid ary = self.random_bytes(16).unpack("NnnnnN") ary[2] = (ary[2] & 0x0fff) | 0x4000 ary[3] = (ary[3] & 0x3fff) | 0x8000 "%08x-%04x-%04x-%04x-%04x%08x" % ary end unless respond_to?(:uuid) end end class Object def blank? respond_to?(:empty?) ? empty? : !self end end
Version data entries
58 entries across 58 versions & 1 rubygems