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
-
#index_by ⇒ Object
File activesupport/lib/active_support/core_ext/enumerable.rb, line 94.
- #uniq_by ⇒ Object
Instance Method Details
#index_by ⇒ Object
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 |
#uniq_by ⇒ Object
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 |