Module: Enumerable

Included in:
Bio::FlatFile, Mspire::Ident::Peptide::Db::IO, Mspire::Mzml, Mspire::Mzml::IOIndex, Mspire::SpectrumLike
Defined in:
lib/core_ext/enumerable.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) index_by

File activesupport/lib/active_support/core_ext/enumerable.rb, line 94



4
5
6
7
# File 'lib/core_ext/enumerable.rb', line 4

def index_by
  return to_enum :index_by unless block_given?
  Hash[map { |elem| [yield(elem), elem] }]
end

- (Object) uniq_by



9
10
11
12
# File 'lib/core_ext/enumerable.rb', line 9

def uniq_by
  h = {}
  inject([]) {|a,x| h[yield(x)] ||= a << x}
end