Sha256: eac4833072db0a9d5f808a9818df829249a0264478fd2fc1a98db3204775f1e4

Contents?: true

Size: 1.35 KB

Versions: 11

Compression:

Stored size: 1.35 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: message)

          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 [String]
        def message
          "No compression for #{original_size} objects " \
          "-> #{compress_size} characters"
        end

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

      end # Simple

    end # Compressors

  end # Output

end # Vedeu

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vedeu-0.8.31 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.30 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.29 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.28 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.27 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.26 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.25 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.24 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.23 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.22 lib/vedeu/output/compressors/simple.rb
vedeu-0.8.21 lib/vedeu/output/compressors/simple.rb