Sha256: 8b6541d82609868c6cffe9da7de1dffa280397417188018aa832c94d898ddb12
Contents?: true
Size: 640 Bytes
Versions: 1
Compression:
Stored size: 640 Bytes
Contents
module Stamp module Emitters class Composite include Enumerable def initialize @emitters = [] end def format(target) # NOTE using #each to build string because benchmarking shows # that it's ~20% faster than .map.join('') result = '' @emitters.each { |e| result << e.format(target).to_s } result end def <<(emitter) if emitter.is_a?(Enumerable) emitter.each { |e| @emitters << e } else @emitters << emitter end end def each(&block) @emitters.each(&block) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stamp-0.5.0 | lib/stamp/emitters/composite.rb |