Sha256: be0a5b1cfe9587e7ce66371b6698d5e46db6c54bfe38670136ede0022915f55b
Contents?: true
Size: 1.26 KB
Versions: 4
Compression:
Stored size: 1.26 KB
Contents
module Vedeu # During the conversion of a Vedeu::Char object into a string of escape # sequences, this class removes multiple occurences of the same escape # sequence, resulting in a smaller payload being sent to the renderer. class Compressor # @param output [Array<Array<Vedeu::Char>>] # @return [Vedeu::Compressor] def initialize(output) @output = output @colour = '' @style = '' end # @return [String] def render Array(output).flatten.map do |char| if char.is_a?(Vedeu::Char) out = '' out << char.position.to_s out << colour_for(char) out << style_for(char) out << char.value out else char.to_s end end.join end protected # @!attribute [r] output # @return [Array<Array<Vedeu::Char>>] attr_reader :output private # @param char [Vedeu::Char] # @return [String] def colour_for(char) return '' if char.colour == @colour @colour = char.colour @colour.to_s end # @param char [Vedeu::Char] # @return [String] def style_for(char) return '' if char.style == @style @style = char.style @style.to_s end end # Compressor end # Vedeu
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.4.22 | lib/vedeu/output/compressor.rb |
vedeu-0.4.21 | lib/vedeu/output/compressor.rb |
vedeu-0.4.20 | lib/vedeu/output/compressor.rb |
vedeu-0.4.19 | lib/vedeu/output/compressor.rb |