Sha256: e2ea7bb6a43c862e0c8248faa8243f1fb0d8140d1b290b744cf9e0f4a3cbdd5b

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module Vedeu

  module Output

    module Compressors

      # A simple compressor which does not compress- it converts each
      # buffer object into a string and returns the resulting blob of
      # text.
      #
      # @api private
      #
      class Simple

        # @param (see #initialize)
        # @return (see #with)
        def self.with(content)
          new(content).with
        end

        # @param content [Array<void>]
        # @return [Vedeu::Output::Compressors::Simple]
        def initialize(content)
          @content = content
        end

        # @return [String]
        def with
          Vedeu.log(type:    :compress,
                    message: "No compression for #{original_size} objects -> " \
                             "#{compress_size} characters")

          compress
        end

        protected

        # @!attribute [r] content
        # @return [void]
        attr_reader :content

        private

        # @return [String]
        def compress
          @_compress ||= content.map(&:to_s).join
        end

        # @return [Fixnum]
        def compress_size
          compress.size
        end

        # @return [Fixnum]
        def original_size
          content.size
        end

      end # Simple

    end # Compressors

  end # Output

end # Vedeu

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
vedeu-0.8.20 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.19 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.18 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.17 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.16 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.15 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.14 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.13 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.12 lib/vedeu/output/compressors/simple.rb