in_groups

in_groups(number, fill_with = nil) Instance Public methods Splits or iterates over the array in number of groups, padding any remaining slots with fill_with unless it is false. %w(1 2 3 4 5 6 7 8 9 10).in_groups(3) {|group| p group} ["1", "2", "3", "4"] ["5", "6", "7", nil] ["8", "9", "10", nil] %w(1 2 3 4 5 6 7 8 9 10).in_groups(3, ' ') {|group| p group} ["1", "2", "3", "4"] ["5", "6", "7", " "] ["8", "9", "10", " "] %w(1 2 3 4 5 6 7).in_groups(3, fals

in_groups_of

in_groups_of(number, fill_with = nil) Instance Public methods Splits or iterates over the array in groups of size number, padding any remaining slots with fill_with unless it is false. %w(1 2 3 4 5 6 7 8 9 10).in_groups_of(3) {|group| p group} ["1", "2", "3"] ["4", "5", "6"] ["7", "8", "9"] ["10", nil, nil] %w(1 2 3 4 5).in_groups_of(2, ' ') {|group| p group} ["1", "2"] ["3", "4"] ["5", " "] %w(1 2 3 4 5).in_groups_of(2, false) {|group| p group} ["1", "2"] ["3",

second

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

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]]

third

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

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) # => []

to_default_s

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

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_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_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"