squish!

squish!() Instance Public methods Performs a destructive squish. See #squish.

strip_heredoc

strip_heredoc() Instance Public methods Strips indentation in heredocs. For example in if options[:usage] puts <<-USAGE.strip_heredoc This command does such and such. Supported options are: -h This message ... USAGE end the user would see the usage message aligned against the left margin. Technically, it looks for the least indented line in the whole string, and removes that amount of leading whitespace.

tableize

tableize() Instance Public methods Creates the name of a table like Rails does for models to table names. This method uses the pluralize method on the last word in the string. 'RawScaledScorer'.tableize # => "raw_scaled_scorers" 'egg_and_ham'.tableize # => "egg_and_hams" 'fancyCategory'.tableize # => "fancy_categories"

titlecase

titlecase() Instance Public methods Alias for: titleize

titleize

titleize() Instance Public methods Capitalizes all the words and replaces some characters in the string to create a nicer looking title. titleize is meant for creating pretty output. It is not used in the Rails internals. titleize is also aliased as titlecase. 'man from the boondocks'.titleize # => "Man From The Boondocks" 'x-men: the last stand'.titleize # => "X Men: The Last Stand" titlecase

to

to(position) Instance Public methods Returns a substring from the beginning of the string to the given position. If the position is negative, it is counted from the end of the string. str = "hello" str.to(0) # => "h" str.to(3) # => "hell" str.to(-2) # => "hell" You can mix it with from method and do fun things like: str = "hello" str.from(0).to(-1) # => "hello" str.from(1).to(-2) # => "ell"

to_date

to_date() Instance Public methods Converts a string to a Date value. "1-1-2012".to_date # => Sun, 01 Jan 2012 "01/01/2012".to_date # => Sun, 01 Jan 2012 "2012-12-13".to_date # => Thu, 13 Dec 2012 "12/13/2012".to_date # => ArgumentError: invalid date

to_datetime

to_datetime() Instance Public methods Converts a string to a DateTime value. "1-1-2012".to_datetime # => Sun, 01 Jan 2012 00:00:00 +0000 "01/01/2012 23:59:59".to_datetime # => Sun, 01 Jan 2012 23:59:59 +0000 "2012-12-13 12:50".to_datetime # => Thu, 13 Dec 2012 12:50:00 +0000 "12/13/2012".to_datetime # => ArgumentError: invalid date

to_time

to_time(form = :local) Instance Public methods Converts a string to a Time value. The form can be either :utc or :local (default :local). The time is parsed using Time.parse method. If form is :local, then the time is in the system timezone. If the date part is missing then the current date is used and if the time part is missing then it is assumed to be 00:00:00. "13-12-2012".to_time # => 2012-12-13 00:00:00 +0100 "06:12".to_time # => 2012-12

truncate

truncate(truncate_at, options = {}) Instance Public methods Truncates a given text after a given length if text is longer than length: 'Once upon a time in a world far far away'.truncate(27) # => "Once upon a time in a wo..." Pass a string or regexp :separator to truncate text at a natural break: 'Once upon a time in a world far far away'.truncate(27, separator: ' ') # => "Once upon a time in a..." 'Once upon a time in a world far far away'.truncate(27, separator: /\s/) # =