Tutorial by Examples

String#at Returns a substring of a string object. Same interface as String#[]. str = "hello" str.at(0) # => "h" str.at(1..3) # => "ell" str.at(-2) # => "l" str.at(-2..-1) # => "lo" str.at(5) # => nil str.at(5..-...
String#to_time Converts a string to a Time value. The form parameter can be either :utc or :local, defaults to :local. "13-12-2012".to_time # => 2012-12-13 00:00:00 +0100 "06:12".to_time # => 2012-12-13 06:12:00 +0100 "2012-12-13 06...
String#exclude? The inverse of String#include? "hello".exclude? "lo" # => false "hello".exclude? "ol" # => true "hello".exclude? ?h # => false
String#squish Returns a version of the given string without leading or trailing whitespace, and combines all consecutive whitespace in the interior to single spaces. Destructive version squish! operates directly on the string instance. Handles both ASCII and Unicode whitespace. %{ Multi-line ...
String#pluralize Returns of plural form of the string. Optionally takes a count parameter and returns singular form if count == 1. Also accepts a locale parameter for language-specific pluralization. 'post'.pluralize # => "posts" 'octopus'.pluralize # => &quot...

Page 1 of 1