Module: Enumerable
- Defined in:
- lib/homeschool.rb
Instance Method Summary collapse
- #average(&block) ⇒ Object
- #intersect(other) ⇒ Object
- #max_by(&block) ⇒ Object
- #min_by(&block) ⇒ Object
- #without(*args) ⇒ Object
Instance Method Details
#average(&block) ⇒ Object
107 108 109 |
# File 'lib/homeschool.rb', line 107 def average(&block) sum(&block)/length end |
#intersect(other) ⇒ Object
98 99 100 |
# File 'lib/homeschool.rb', line 98 def intersect(other) select &other.method(:include?) end |
#max_by(&block) ⇒ Object
104 105 106 |
# File 'lib/homeschool.rb', line 104 def max_by(&block) max {|a,b| block.call(a) <=> block.call(b)} end |
#min_by(&block) ⇒ Object
101 102 103 |
# File 'lib/homeschool.rb', line 101 def min_by(&block) min {|a,b| block.call(a) <=> block.call(b)} end |
#without(*args) ⇒ Object
95 96 97 |
# File 'lib/homeschool.rb', line 95 def without(*args) reject &args.method(:include?) end |