Sha256: 6f5e96847d63f1494bcdd5e65b7cb96aee74709a366138b382b4584aa6ce9896
Contents?: true
Size: 1.74 KB
Versions: 7
Compression:
Stored size: 1.74 KB
Contents
module Vedeu module Renderers # 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. # # @api private class File # @param output [Array<Array<Vedeu::Char>>] # @param options [Hash] # @return [String] def self.render(output, options = {}) new(output, options).render end # Returns a new instance of Vedeu::Renderers::File. # # @param output [Array<Array<Vedeu::Char>>] # @param options [Hash] # @return [Vedeu::Renderers::File] def initialize(output, options = {}) @output = output @options = options end # @return [String] def render ::File.open(path, 'w') { |f| f.write(parsed) } parsed end protected # @!attribute [r] output # @return [Array<Array<Vedeu::Char>>] attr_reader :output private # @return [String] def path "/tmp/#{filename}" end # @return [String] def filename if timestamp? "out_#{timestamp}" else 'out' end end # @return [String] def parsed @parsed ||= Vedeu::Compressor.render(output) end # @return [Float] def timestamp @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 # File end # Renderers end # Vedeu
Version data entries
7 entries across 7 versions & 1 rubygems