class Futuroscope::Map
A futuroscope map behaves like a regular map but performs all operations using futures so they're effectively parallel.
Public Class Methods
new(items)
click to toggle source
Initializes a map with a set of items.
items - Items in which to perform the mapping
# File lib/futuroscope/map.rb, line 12 def initialize(items) @items = items end
Public Instance Methods
map(&block)
click to toggle source
Maps each item with a future.
block - A block that will be executed passing each element as a parameter
Returns an array of futures that behave like the original objects.
# File lib/futuroscope/map.rb, line 21 def map(&block) @items.map do |item| Future.new do block.call(item) end end end