Sha256: 022ab4170ef220b5a413d1e5fb710060ec3611dbaf43174a84a9f7d3509ff303

Contents?: true

Size: 516 Bytes

Versions: 11

Compression:

Stored size: 516 Bytes

Contents

require 'delegate'

# A delegator that allows the size method to be used on the STDOUT object.
#
# The size of the content written to STDOUT cannot be measured normally. This
# class wraps the STDOUT object so the cumulative size of the content passed to
# the write method (while wrapped in this decorator) can be measured.
class QuantifiableStdout < SimpleDelegator
  attr_reader :size

  def initialize delegate
    @size = 0
    super
  end

  def write content
    @size += content.bytesize
    super
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
asciidoctor-pdf-1.5.0.beta.1 lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
asciidoctor-pdf-1.5.0.alpha.18 lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
asciidoctor-pdf-1.5.0.alpha.17 lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
asciidoctor-pdf-1.5.0.alpha.16 lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
asciidoctor-pdf-1.5.0.alpha.15 lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
asciidoctor-pdf-1.5.0.alpha.14 lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
asciidoctor-pdf-1.5.0.alpha.13 lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
asciidoctor-pdf-1.5.0.alpha.12 lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
asciidoctor-pdf-1.5.0.alpha.11 lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
asciidoctor-pdf-1.5.0.alpha.10 lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
asciidoctor-pdf-1.5.0.alpha.9 lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb