Sha256: edd98e8becb389c25fe2b2064f898f6be7d0532999a766a8f6853252c92f2449
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
# # ActiveFacts Runtime API. # Various additions or patches to Ruby built-in classes, and some global support methods # # Copyright (c) 2009 Clifford Heath. Read the LICENSE file. # # Define Infinity as a constant, if it's not already defined: # We use this to define open-ended ranges. unless Object.const_defined?("Infinity") Infinity = 1.0/0.0 end class String #:nodoc: # This may be overridden by a version from ActiveSupport. For our purposes, either will work. def camelcase(first_letter = :upper) if first_letter == :upper gsub(/(^|[_\s]+)([A-Za-z])/){ $2.upcase } else gsub(/([_\s]+)([A-Za-z])/){ $2.upcase } end end def snakecase gsub(/([^_])([A-Z][a-z])/,'\1_\2').downcase end def camelwords gsub(/-([a-zA-Z])/){ $1.upcase }. # Break and upcase on hyphenated words gsub(/([a-z])([A-Z])/,'\1_\2'). split(/[_\s]+/) end end class Module #:nodoc: def modspace space = name[ 0...(name.rindex( '::' ) || 0)] space == '' ? Object : eval(space) end def basename name.gsub(/.*::/, '') end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activefacts-api-1.9.13 | lib/activefacts/api/support.rb |
activefacts-api-1.9.12 | lib/activefacts/api/support.rb |
activefacts-api-1.9.11 | lib/activefacts/api/support.rb |