Class: GraphQL::Language::Printer::TruncatableBuffer
- Inherits:
-
Object
- Object
- GraphQL::Language::Printer::TruncatableBuffer
show all
- Defined in:
- lib/graphql/language/printer.rb
Defined Under Namespace
Classes: TruncateSizeReached
Constant Summary
collapse
- DEFAULT_INIT_CAPACITY =
500
Instance Method Summary
collapse
Constructor Details
12
13
14
15
|
# File 'lib/graphql/language/printer.rb', line 12
def initialize(truncate_size: nil)
@out = String.new(capacity: truncate_size || DEFAULT_INIT_CAPACITY)
@truncate_size = truncate_size
end
|
Instance Method Details
#append(other) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/graphql/language/printer.rb', line 17
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
|
#to_string ⇒ Object
26
27
28
|
# File 'lib/graphql/language/printer.rb', line 26
def to_string
@out
end
|