Sha256: 91980ba33d0c91e31d4033da26a8af536a2ea39d48e241a282cefa00a79cc622
Contents?: true
Size: 978 Bytes
Versions: 2
Compression:
Stored size: 978 Bytes
Contents
module Twitter module Utils module_function # Returns a new array with the concatenated results of running block once for every element in enumerable. # If no block is given, an enumerator is returned instead. # # @param enumerable [Enumerable] # @return [Array, Enumerator] def flat_pmap(enumerable, &block) return to_enum(:flat_pmap, enumerable) unless block_given? pmap(enumerable, &block).flatten(1) end # Returns a new array with the results of running block once for every element in enumerable. # If no block is given, an enumerator is returned instead. # # @param enumerable [Enumerable] # @return [Array, Enumerator] def pmap(enumerable, &block) return to_enum(:pmap, enumerable) unless block_given? if enumerable.count == 1 enumerable.collect(&block) else enumerable.collect { |object| Thread.new { yield(object) } }.collect(&:value) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
twitter-8.0.0 | lib/twitter/utils.rb |
twitter-8.0.0.rc.1 | lib/twitter/utils.rb |