Sha256: f9acaa8879935736225c3011c6a717d4efd18576a62bd901b56ff5eaa192aa61

Contents?: true

Size: 576 Bytes

Versions: 3

Compression:

Stored size: 576 Bytes

Contents

class String
    
  ##
  # Replace +hash+ keys with associated values. Mutative.
  
  def tokenize! hash
    hash.inject(self) { |s, (k, v)| s.gsub! /:#{k}/, v }
  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

3 entries across 3 versions & 1 rubygems

Version Path
visionmedia-commander-2.4.3 lib/commander/core_ext/string.rb
visionmedia-commander-2.4.4 lib/commander/core_ext/string.rb
visionmedia-commander-2.4.6 lib/commander/core_ext/string.rb