Adds helpful methods and new syntax to existing methods to improve readability and expressiveness.
Examples will explain best:
require 'pretty_ruby'
using PrettyRuby
# map methods that require arguments
arr = [ ['a', 'b', 'c'], ['d', 'e', 'f'] ]
arr.map(:join, '-') #=> [ 'a-b-c', 'd-e-f' ]
# use >> as a pipeline operator
arr = 'hello'.chars
arr.map(:next >> :upcase).join('-') #=> "I-F-M-M-P"
# support negative take and drop
arr = [1, 2, 3, 4, 5]
arr.take(-2) # => [4, 5]
arr.drop(-2) # => [1, 2, 3]
# add tail / init
arr.tail # => [2, 3, 4, 5]
arr.init # => [1, 2, 3, 4]
# scan without arguments
'abcde'.scan #=> ["a", "ab", "abc", "abcd", "abcde"]
# scan with arguments
arr = [1, 2, 3, 4, 5]
arr.scan(:+) #=> [1, 3, 6, 10, 15]
arr.scan(:*) #=> [1, 2, 6, 24, 120]Document other features
Go through the remaining Enumerable and Array methods to support the new syntax where relevant.
countdetectfind_indexfind_allselectrejectcollectmapflat_mapcollect_concatinjectreducepartitiongroup_byfirstall?any?one?none?minmaxminmax_bymember?each_with_indexreverse_eacheach_entryeach_sliceeach_conseach_with_objectziptaketake_whiledropdrop_whilecyclechunkslice_beforeslice_afterslice_whenchunk_whilesumuniq