lib/intact_case/modules.rb
#
# Convert compound words connected by a delimiter from camelCase|StudlyCaps.
#
# @author StewEucen
# @example camelCase|StudlyCaps to delimiterized.
#   'camelCase'.delimiterize             #=> 'camel_case'
#   'StudlyCaps'.delimiterize('_', true) #=> '_studly_caps'
#   'chainCase'.delimiterize('-')        #=> 'chain-case'
#   'getUTCDay'.delimiterize             #=> 'get_utc__day'
#   'UIView'.delimiterize                #=> 'ui__view'
#   'XML_HTMLRequest'.delimiterize       #=> 'xml__html__request'
# @param  [string] delimiter Concatenate tokens with between delimiter.
# @param  [boolean] as_vendor_prefix Treat as vendor-prefix (CSS).
# @return [string] Delimiterized compound words.
# @since  Release 1.0.0
#
Convert compound words connected by a delimiter from camelCase|StudlyCaps.
Convert compound words connected by a delimiter from camelCase|StudlyCaps .
def delimiterize(delimiter = '_', as_vendor_prefix = false)
          d = Regexp.escape(delimiter)
          before_acronym = "(?:^[a-z]{2,}#{d}|[a-z])(?=[A-Z](?![a-z]))"
          after_acronym  = "[A-Z]{2,}(?![a-z])"
          before_capital = "(?!^)(?=[A-Z][a-z])"
          p = /#{before_acronym}|#{after_acronym}|#{before_capital}/;
          head_delimiter = as_vendor_prefix && /^[A-Z]/ =~ self ? delimiter : ''
          head_delimiter + self.gsub(p) { $& + delimiter }.downcase
        end
def delimiterize ( delimiter = '_' , as_vendor_prefix = false ) d = Regexp . escape ( delimiter ) before_acronym = "(?:^[a-z]{2,}#{d}|[a-z])(?=[A-Z](?![a-z]))" after_acronym = "[A-Z]{2,}(?![a-z])" before_capital = "(?!^)(?=[A-Z][a-z])" p = / #{ before_acronym } | #{ after_acronym } | #{ before_capital } / ; head_delimiter = as_vendor_prefix && / ^[A-Z] / =~ self ? delimiter : '' head_delimiter + self . gsub ( p ) { $& + delimiter } . downcase end
Convert compound words connected by a delimiter from camelCase|StudlyCaps.
Convert compound words connected by a delimiter from camelCase|StudlyCaps .
Delimiterized compound words.
Delimiterized compound words .
string
delimiter
as_vendor_prefix
as_vendor_prefix Treat as vendor-prefix (CSS).
as_vendor_prefix Treat as vendor - prefix ( CSS ) .
author
None
example
camelCase|StudlyCaps to delimiterized.
camelCase|StudlyCaps to delimiterized .
since
None