summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2015-07-28 01:51:48 -0600
committerDan Allen <dan.j.allen@gmail.com>2015-07-28 01:51:48 -0600
commit9937eeafee40a1432c04a82fa8d072a3cc89d39f (patch)
tree00749962c438cf32c5d03e0bcd9d6d607a6c8ed6
parent406c2d323cfa82fc6df87e2eb1e3b099d9309e92 (diff)
add missing class from fix for #254
-rw-r--r--lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb b/lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
new file mode 100644
index 00000000..1e44cecb
--- /dev/null
+++ b/lib/asciidoctor-pdf/core_ext/quantifiable_stdout.rb
@@ -0,0 +1,20 @@
+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