first

first(limit = 1) Instance Public methods Returns the first character. If a limit is supplied, returns a substring from the beginning of the string until it reaches the limit value. If the given limit is greater than or equal to the string length, returns self. str = "hello" str.first # => "h" str.first(1) # => "h" str.first(2) # => "he" str.first(0) # => "" str.first(6) # => "hello"

exclude?

exclude?(string) Instance Public methods The inverse of String#include?. Returns true if the string does not include the other string. "hello".exclude? "lo" # => false "hello".exclude? "ol" # => true "hello".exclude? ?h # => false

demodulize

demodulize() Instance Public methods Removes the module part from the constant expression in the string. 'ActiveRecord::CoreExtensions::String::Inflections'.demodulize # => "Inflections" 'Inflections'.demodulize # => "Inflections" See also deconstantize.

deconstantize

deconstantize() Instance Public methods Removes the rightmost segment from the constant expression in the string. 'Net::HTTP'.deconstantize # => "Net" '::Net::HTTP'.deconstantize # => "::Net" 'String'.deconstantize # => "" '::String'.deconstantize # => "" ''.deconstantize # => "" See also demodulize.

dasherize

dasherize() Instance Public methods Replaces underscores with dashes in the string. 'puni_puni'.dasherize # => "puni-puni"

constantize

constantize() Instance Public methods constantize tries to find a declared constant with the name specified in the string. It raises a NameError when the name is not in CamelCase or is not initialized. See ActiveSupport::Inflector#constantize 'Module'.constantize # => Module 'Class'.constantize # => Class 'blargle'.constantize # => NameError: wrong constant name blargle

classify

classify() Instance Public methods Create a class name from a plural table name like Rails does for table names to models. Note that this returns a string and not a class. (To convert to an actual class follow classify with constantize.) 'egg_and_hams'.classify # => "EggAndHam" 'posts'.classify # => "Post"

camelize

camelize(first_letter = :upper) Instance Public methods By default, camelize converts strings to UpperCamelCase. If the argument to camelize is set to :lower then camelize produces lowerCamelCase. camelize will also convert '/' to '::' which is useful for converting paths to namespaces. 'active_record'.camelize # => "ActiveRecord" 'active_record'.camelize(:lower) # => "activeRecord" 'active_record/errors'.camelize # => "ActiveRecord::Errors" '

camelcase

camelcase(first_letter = :upper) Instance Public methods Alias for: camelize

blank?

blank?() Instance Public methods A string is blank if it's empty or contains whitespaces only: ''.blank? # => true ' '.blank? # => true "\t\n\r".blank? # => true ' blah '.blank? # => false Unicode whitespace is supported: "\u00a0".blank? # => true @return [true, false]