Sha256: 27482b7c203b447cd45c845e756af81769a350fa99023718348099880589b03f
Contents?: true
Size: 904 Bytes
Versions: 1
Compression:
Stored size: 904 Bytes
Contents
require 'futuroscope/future' module Futuroscope # A futuroscope map behaves like a regular map but performs all operations # using futures so they're effectively parallel. # class Map # Initializes a map with a set of items. # # items - Items in which to perform the mapping # def initialize(items) @items = items end # 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. def map(&block) @items.map do |item| Future.new do block.call(item) end end end private def method_missing(method, *args) @map.send(method, *args) end def respond_to_missing?(method, include_private = false) @map.respond_to?(method, include_private) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
futuroscope-0.0.2 | lib/futuroscope/map.rb |