From a1f47fbf19b859c8e680a0a92eff5e225a015090 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 18 Dec 2013 23:07:20 +1100 Subject: [PATCH] create Util module with threaded_map method --- lib/twitter.rb | 1 + lib/twitter/util.rb | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 lib/twitter/util.rb diff --git a/lib/twitter.rb b/lib/twitter.rb index cc2bb46ff..f1c2eb39d 100644 --- a/lib/twitter.rb +++ b/lib/twitter.rb @@ -29,3 +29,4 @@ require 'twitter/trend' require 'twitter/tweet' require 'twitter/user' +require 'twitter/util' diff --git a/lib/twitter/util.rb b/lib/twitter/util.rb new file mode 100644 index 000000000..e4de33f03 --- /dev/null +++ b/lib/twitter/util.rb @@ -0,0 +1,9 @@ +module Twitter + module Util + def self.threaded_map(enumerable) + enumerable.map { |object| + Thread.new { yield object } + }.map(&:value) + end + end +end