Class: Fluent::Plugin::JsonSizeLimit::RecordReducer::StringLocation

Inherits:
JsonString
  • Object
show all
Defined in:
lib/fluent/plugin/json_size_limit/record_reducer.rb

Constant Summary

Constants inherited from JsonString

JsonString::COUNT_SCAN_THRESHOLD, JsonString::ESCAPED_CHARACTERS, JsonString::ESCAPE_REQUIRED, JsonString::UTF_8

Instance Attribute Summary collapse

Attributes inherited from JsonString

#content_bytes, #truncated_content_bytes, #value

Instance Method Summary collapse

Methods inherited from JsonString

content_bytes, truncate, #truncate

Constructor Details

#initialize(container, key, value, encoding_validated: false) ⇒ StringLocation

Returns a new instance of StringLocation.



21
22
23
24
25
26
27
28
29
# File 'lib/fluent/plugin/json_size_limit/record_reducer.rb', line 21

def initialize(container, key, value, encoding_validated: false)
  super(value, validate_encoding: !encoding_validated)
  @container = container
  @key = key
  @original_value = value
  @occurrences = 1
  @replacement_value = value
  @replacement_content_bytes = content_bytes
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



18
19
20
# File 'lib/fluent/plugin/json_size_limit/record_reducer.rb', line 18

def container
  @container
end

#keyObject (readonly)

Returns the value of attribute key.



18
19
20
# File 'lib/fluent/plugin/json_size_limit/record_reducer.rb', line 18

def key
  @key
end

#occurrencesObject

Returns the value of attribute occurrences.



19
20
21
# File 'lib/fluent/plugin/json_size_limit/record_reducer.rb', line 19

def occurrences
  @occurrences
end

#original_valueObject (readonly)

Returns the value of attribute original_value.



18
19
20
# File 'lib/fluent/plugin/json_size_limit/record_reducer.rb', line 18

def original_value
  @original_value
end

#replacement_content_bytesObject

Returns the value of attribute replacement_content_bytes.



19
20
21
# File 'lib/fluent/plugin/json_size_limit/record_reducer.rb', line 19

def replacement_content_bytes
  @replacement_content_bytes
end

#replacement_valueObject

Returns the value of attribute replacement_value.



19
20
21
# File 'lib/fluent/plugin/json_size_limit/record_reducer.rb', line 19

def replacement_value
  @replacement_value
end

Instance Method Details

#truncate_to(content_budget) ⇒ Object



31
32
33
34
# File 'lib/fluent/plugin/json_size_limit/record_reducer.rb', line 31

def truncate_to(content_budget)
  @replacement_value = truncate(content_budget)
  @replacement_content_bytes = truncated_content_bytes
end