Sha256: c75f674fff04643180fb9c8352ff07709d5f63a24a4627e73dfe1c7b48dda408

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Vedeu

  module Output

    module Compressors

      # The empty compressor removes all empty cells.
      #
      # @api private
      #
      class Empty

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

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

        # @return [Array]
        def compress
          Vedeu.timer('Removing empty cells...') do
            content.reject { |cell| cell.class == Vedeu::Cells::Empty }
          end.tap do |out|
            Vedeu.log(type:    :compress,
                      message: "#{message} -> #{out.size} objects")
          end
        end

        protected

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

        private

        # @return [String]
        def message
          "Compression for #{content.size} objects"
        end

      end # Empty

    end # Compressors

  end # Output

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.8.32 lib/vedeu/output/compressors/empty.rb