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

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

from

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

fourth

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

forty_two

forty_two() Instance Public methods Equal to self[41]. Also known as accessing âthe redditâ. (1..42).to_a.forty_two # => 42

fifth

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

extract_options!

extract_options!() Instance Public methods Extracts options from a set of arguments. Removes and returns the last element in the array if it's a hash, otherwise returns a blank hash. def options(*args) args.extract_options! end options(1, 2) # => {} options(1, 2, a: :b) # => {:a=>:b}

deep_dup

deep_dup() Instance Public methods Returns a deep copy of array. array = [1, [2, 3]] dup = array.deep_dup dup[1][2] = 4 array[1][2] # => nil dup[1][2] # => 4

wrap

wrap(object) Class Public methods Wraps its argument in an array unless it is already an array (or array-like). Specifically: If the argument is nil an empty list is returned. Otherwise, if the argument responds to to_ary it is invoked, and its result returned. Otherwise, returns an array with the argument as its single element. Array.wrap(nil) # => [] Array.wrap([1, 2, 3]) # => [1, 2, 3] Array.wrap(0) # => [0] This method is similar in purpose to K

version

version() Class Public methods Returns the version of the currently loaded ActiveSupport as a Gem::Version