Sha256: 9f3e20e647bba408aae01c093a414608b49ae773a276fbd19a73ab3b7c2879d9

Contents?: true

Size: 585 Bytes

Versions: 2

Compression:

Stored size: 585 Bytes

Contents

class String
    
  ##
  # Replace +hash+ keys with associated values. Mutative.
  
  def tokenize! hash = {}
    hash.each { |k, v| gsub! /:#{k}/, v.to_s }
    self
  end
    
  ##
  # Replace +hash+ keys with associated values.
  
  def tokenize hash = {}
    self.dup.tokenize! hash
  end
  
  ##
  # Converts a string to camelcase.
  
  def camelcase upcase_first_letter = true
    up = upcase_first_letter
    s = dup
    s.gsub!(/\/(.?)/){ "::#{$1.upcase}" }
    s.gsub!(/(?:_+|-+)([a-z])/){ $1.upcase }
    s.gsub!(/(\A|\s)([a-z])/){ $1 + $2.upcase } if up
    s
  end
    
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
visionmedia-commander-2.5.6 lib/commander/core_ext/string.rb
visionmedia-commander-2.5.7 lib/commander/core_ext/string.rb