👻 Ruby Enumerable

Enumerable

method takes a block
method takes no args
something else
Enumerablemethod takes a block…
yes/no
yes/no
info / stats
info / stats
iterate / loop
iterate / loop
sort
sort
retrieve one instance
retrieve one instance
filter out subset
filter out subset
transform
transform

with block
#all? {block}
#any? {block}
#none? {block}

with block…

with object
#include? (obj)

with object…

#count
#count {block}
#min
#min {|a, b| …}
#min_by {block}
#max
#max {|a, b| …}
#max_by {block}
#minmax
#minmax{|a, b| …}
#minmax_by {block

#count…

staggered loops
#each_corns(n) {block}
#each_slice(n) {block}

staggered loops…
#each {block}
#each_with_object (o) {|el,o| … }
#each_with_index {|el, i| … }
#each {block}…

#sort
#sort { |a,b| …}
#sort_by {block}
#reverse

#sort…
#find {block}
#first
#last
#find {block}…

by amount
#drop (n)
#take (n)
by block
#drop_while {block}
#take_while {block}
#find_all {block}
#reject {block}
reject {block}
by pattern
#grep /pattern/

by amount…
#inject {block}
#map {block}
#partition {block}
#chunk {block}
#group_by {block}
#inject {block}…
Viewer does not support full SVG 1.1

Zane Zheng
Zane Zheng
Full Stack (Ruby on Rails) / Devops

An Full Stack / Devops with JS, Ruby, Linux, JAMStack, MicroServices.

Related