Class: Ibex::Runtime::SyntaxSessionLimits
- Inherits:
-
Object
- Object
- Ibex::Runtime::SyntaxSessionLimits
- Defined in:
- lib/ibex/runtime/syntax_session.rb,
sig/ibex/runtime/syntax_session.rbs
Overview
Immutable syntax-service bounds layered over parser ResourceLimits.
Constant Summary collapse
- DEFAULT_MAX_SOURCE_BYTES =
16 * 1024 * 1024
- DEFAULT_MAX_EDITS_PER_OPERATION =
1_024- DEFAULT_MAX_INSERTED_BYTES =
4 * 1024 * 1024
Instance Attribute Summary collapse
- #max_edits_per_operation ⇒ Integer readonly
- #max_inserted_bytes ⇒ Integer readonly
- #max_source_bytes ⇒ Integer readonly
Instance Method Summary collapse
-
#initialize(max_source_bytes: DEFAULT_MAX_SOURCE_BYTES, max_edits_per_operation: DEFAULT_MAX_EDITS_PER_OPERATION, max_inserted_bytes: DEFAULT_MAX_INSERTED_BYTES) ⇒ SyntaxSessionLimits
constructor
A new instance of SyntaxSessionLimits.
- #validate_nonnegative_integer(value, name) ⇒ void
- #validate_positive_integer(value, name) ⇒ void
Constructor Details
#initialize(max_source_bytes: DEFAULT_MAX_SOURCE_BYTES, max_edits_per_operation: DEFAULT_MAX_EDITS_PER_OPERATION, max_inserted_bytes: DEFAULT_MAX_INSERTED_BYTES) ⇒ SyntaxSessionLimits
Returns a new instance of SyntaxSessionLimits.
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ibex/runtime/syntax_session.rb', line 75 def initialize( max_source_bytes: DEFAULT_MAX_SOURCE_BYTES, max_edits_per_operation: DEFAULT_MAX_EDITS_PER_OPERATION, max_inserted_bytes: DEFAULT_MAX_INSERTED_BYTES ) validate_positive_integer(max_source_bytes, :max_source_bytes) validate_positive_integer(max_edits_per_operation, :max_edits_per_operation) validate_nonnegative_integer(max_inserted_bytes, :max_inserted_bytes) @max_source_bytes = max_source_bytes @max_edits_per_operation = max_edits_per_operation @max_inserted_bytes = max_inserted_bytes freeze end |
Instance Attribute Details
#max_edits_per_operation ⇒ Integer (readonly)
70 71 72 |
# File 'lib/ibex/runtime/syntax_session.rb', line 70 def max_edits_per_operation @max_edits_per_operation end |
#max_inserted_bytes ⇒ Integer (readonly)
71 72 73 |
# File 'lib/ibex/runtime/syntax_session.rb', line 71 def max_inserted_bytes @max_inserted_bytes end |
#max_source_bytes ⇒ Integer (readonly)
69 70 71 |
# File 'lib/ibex/runtime/syntax_session.rb', line 69 def max_source_bytes @max_source_bytes end |
Instance Method Details
#validate_nonnegative_integer(value, name) ⇒ void
This method returns an undefined value.
99 100 101 102 103 |
# File 'lib/ibex/runtime/syntax_session.rb', line 99 def validate_nonnegative_integer(value, name) return if value.is_a?(Integer) && value >= 0 raise ArgumentError, "#{name} must be a nonnegative Integer" end |
#validate_positive_integer(value, name) ⇒ void
This method returns an undefined value.
92 93 94 95 96 |
# File 'lib/ibex/runtime/syntax_session.rb', line 92 def validate_positive_integer(value, name) return if value.is_a?(Integer) && value.positive? raise ArgumentError, "#{name} must be a positive Integer" end |