Sha256: 6ee7786190a238cbcb5218193d6579a912ee8bd7964e287232020c16e519b47a
Contents?: true
Size: 587 Bytes
Versions: 4
Compression:
Stored size: 587 Bytes
Contents
class Object def blank? respond_to?(:empty?) ? !!empty? : !self end end class String def camelize(first_letter = :upper) case first_letter when :upper Larva::Utils.camelize(self, true) when :lower Larva::Utils.camelize(self, false) end end end module Larva module Utils def self.camelize(term, uppercase_first_letter = true) string = term.to_s string = string.sub(/^[a-z\d]*/) { $&.capitalize } string.gsub!(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" } string.gsub!('/', '::') string end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
larva-1.3.0 | lib/larva/utils.rb |
larva-1.2.0 | lib/larva/utils.rb |
larva-1.1.3 | lib/larva/utils.rb |
larva-1.1.2 | lib/larva/utils.rb |