last

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

is_utf8?

is_utf8?() Instance Public methods

inquiry

inquiry() Instance Public methods Wraps the current string in the ActiveSupport::StringInquirer class, which gives you a prettier way to test for equality. env = 'production'.inquiry env.production? # => true env.development? # => false

indent!

indent!(amount, indent_string=nil, indent_empty_lines=false) Instance Public methods Same as indent, except it indents the receiver in-place. Returns the indented string, or nil if there was nothing to indent.

indent

indent(amount, indent_string=nil, indent_empty_lines=false) Instance Public methods Indents the lines in the receiver: <<EOS.indent(2) def some_method some_code end EOS # => def some_method some_code end The second argument, indent_string, specifies which indent string to use. The default is nil, which tells the method to make a guess by peeking at the first indented line, and fallback to a space if there is none. " foo".indent(2) # => " foo" "foo\

in_time_zone

in_time_zone(zone = ::Time.zone) Instance Public methods Converts String to a TimeWithZone in the current zone if Time.zone or Time.zone_default is set, otherwise converts String to a Time via #to_time

humanize

humanize(options = {}) Instance Public methods Capitalizes the first word, turns underscores into spaces, and strips a trailing '_id' if present. Like titleize, this is meant for creating pretty output. The capitalization of the first word can be turned off by setting the optional parameter capitalize to false. By default, this parameter is true. 'employee_salary'.humanize # => "Employee salary" 'author_id'.humanize # => "Author" 'author_id'.hu

html_safe

html_safe() Instance Public methods

from

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

foreign_key

foreign_key(separate_class_name_and_id_with_underscore = true) Instance Public methods Creates a foreign key name from a class name. separate_class_name_and_id_with_underscore sets whether the method should put '_' between the name and 'id'. 'Message'.foreign_key # => "message_id" 'Message'.foreign_key(false) # => "messageid" 'Admin::Post'.foreign_key # => "post_id"