Class: Smith::DiagnosticText

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer
Defined in:
lib/smith/diagnostic_text.rb

Constant Summary collapse

MAX_BYTES =
64 * 1024

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.capture(value, max_bytes: MAX_BYTES) ⇒ Object



19
# File 'lib/smith/diagnostic_text.rb', line 19

def self.capture(value, max_bytes: MAX_BYTES) = new(value, max_bytes:).call

Instance Method Details

#callObject



21
22
23
24
25
26
27
# File 'lib/smith/diagnostic_text.rb', line 21

def call
  validate_limit!
  text = utf8_prefix
  return text.freeze if text.bytesize <= max_bytes

  truncate(text)
end