lib/facet/symbol/camelcase.rb in facets-0.7.2 vs lib/facet/symbol/camelcase.rb in facets-0.9.0

- old
+ new

@@ -1,24 +2 @@ -class Symbol - # Converts a symbol to camelcase. By default capitalization - # occurs on whitespace and underscores. By setting the first - # parameter to <tt>true</tt> the first character can also be - # captizlized. The second parameter can be assigned a valid - # Regualr Expression characeter set to determine which - # characters to match for capitalizing subsequent parts of - # the string. - # - # require 'facet/string/camelcase' - # - # "this_is a test".camelCase #=> "ThisIsATest" - # "this_is a test".camelCase(false) #=> "thisIsATest" - # "this_is a test".camelCase(false, ' ') #=> "This_isATest" - # - def camelcase(first=false, on='_\s') - if first - (to_s.gsub(/(^|[#{on}]+)([A-Za-z])/){ $2.upcase }).to_sym - else - (to_s.gsub(/([#{on}]+)([A-Za-z])/){ $2.upcase }).to_sym - end - end - alias_method( :camelCase, :camelcase ) -end +require 'nano/symbol/camelcase.rb' \ No newline at end of file