Sha256: 30b68766d218752e6ffce99f0ef1c08cbdca5a1a6ea84310faab3997bbe1c4cb
Contents?: true
Size: 1.67 KB
Versions: 2
Compression:
Stored size: 1.67 KB
Contents
module Vedeu # Provides a single interface to all registered renderers. # module Renderers extend Enumerable extend self def clear threads = storage.map do |renderer| Thread.new(renderer) do mutex.synchronize do renderer.clear end end end threads.each(&:join) '' end # Provides access to the list of renderers. # # @example # Vedeu.renderers # # @return [Module] def renderers self end # @example # Vedeu.renderers.render(output) # # @param output [void] # @return [Array<void>] def render(output) threads = storage.map do |renderer| Thread.new(renderer) do mutex.synchronize do Vedeu.log(type: :output, message: "Renderer: '#{renderer.class.name}'") renderer.render(output) end end end threads.each(&:join) output end # Adds the given renderer class(es) to the list of renderers. # # @example # Vedeu.renderer SomeRenderer # # @note # A renderer class must respond to the '.render' class method. # # @param renderers [Class] # @return [Set] def renderer(*renderers) renderers.each { |renderer| storage.add(renderer) unless renderer.nil? } storage end # @example # Vedeu.renderers.reset # # @return [Set] def reset @storage = Set.new end private # @return [Set] def storage @storage ||= reset end # @return [Mutex] def mutex @mutex ||= Mutex.new end end # Renderers end # Vedeu
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.6.13 | lib/vedeu/output/renderers.rb |
vedeu-0.6.12 | lib/vedeu/output/renderers.rb |