class GraphQL::Language::Printer::TruncatableBuffer
Constants
- DEFAULT_INIT_CAPACITY
Public Class Methods
Source
# File lib/graphql/language/printer.rb, line 13 def initialize(truncate_size: nil) @out = String.new(capacity: truncate_size || DEFAULT_INIT_CAPACITY) @truncate_size = truncate_size end
Public Instance Methods
Source
# File lib/graphql/language/printer.rb, line 18 def append(other) if @truncate_size && (@out.size + other.size) > @truncate_size @out << other.slice(0, @truncate_size - @out.size) raise(TruncateSizeReached, "Truncate size reached") else @out << other end end