Sha256: 9b19ccdee32097b7fca556b43fa6a4a1fa43eab9fb241ef2b856d72fa0ac7526
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
module Vedeu # Converts a grid of {Vedeu::Char} objects into a stream of escape sequences # and content suitable for a terminal, and writes them to a file in the /tmp # directory. # class FileRenderer # @param output [Array<Array<Vedeu::Char>>] # @return [String] def self.render(*output) new(*output).render end # Returns a new instance of Vedeu::FileRenderer. # # @param output [Array<Array<Vedeu::Char>>] # @return [Vedeu::FileRenderer] def initialize(*output) @output = output @options = {} end # @return [String] def render File.open("/tmp/#{filename}", 'w') { |f| f.write(parsed) } end private # @!attribute [r] output # @return [Array<Array<Vedeu::Char>>] attr_reader :output # @return [String] def filename if timestamp? "out_#{timestamp}" else 'out' end end # @return [String] def parsed Vedeu::Compressor.new(output).render end # @return [Float] def timestamp Time.now.to_f end # @return [Boolean] def timestamp? return true if options[:timestamp] false end # @return [Hash] def options defaults.merge!(@options) end # @return [Hash] def defaults { timestamp: false, } end end # FileRenderer end # Vedeu
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.4.15 | lib/vedeu/output/renderers/file_renderer.rb |
vedeu-0.4.14 | lib/vedeu/output/renderers/file_renderer.rb |