to_sentence

to_sentence(options = {}) Instance Public methods Converts the array to a comma-separated sentence where the last element is joined by the connector word. You can pass the following options to change the default behavior. If you pass an option key that doesn't exist in the list below, it will raise an ArgumentError. Options :words_connector - The sign or word used to join the elements in arrays with two or more elements (default: â, â). :two_words_connector - The sign or word us

to_s

to_s(format = :default) Instance Public methods Also aliased as: to_default_s

to_query

to_query(key) Instance Public methods Converts an array into a string suitable for use as a URL query string, using the given key as the param name. ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding"

to_param

to_param() Instance Public methods Calls to_param on all its elements and joins the result with slashes. This is used by url_for in Action Pack.

to_formatted_s

to_formatted_s(format = :default) Instance Public methods Extends Array#to_s to convert a collection of elements into a comma separated id list if :db argument is given as the format. Blog.all.to_formatted_s(:db) # => "1,2,3" to_s

to_default_s

to_default_s(format = :default) Instance Public methods Alias for: to_s

to

to(position) Instance Public methods Returns the beginning of the array up to position. %w( a b c d ).to(0) # => ["a"] %w( a b c d ).to(2) # => ["a", "b", "c"] %w( a b c d ).to(10) # => ["a", "b", "c", "d"] %w().to(0) # => []

third

third() Instance Public methods Equal to self[2]. %w( a b c d e ).third # => "c"

split

split(value = nil) Instance Public methods Divides the array into one or more subarrays based on a delimiting value or the result of an optional block. [1, 2, 3, 4, 5].split(3) # => [[1, 2], [4, 5]] (1..10).to_a.split { |i| i % 3 == 0 } # => [[1, 2], [4, 5], [7, 8], [10]]

second

second() Instance Public methods Equal to self[1]. %w( a b c d e ).second # => "b"