Class: Vapi::RegexReplacement
- Inherits:
-
Object
- Object
- Vapi::RegexReplacement
- Defined in:
- lib/vapi_server_sdk/types/regex_replacement.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#options ⇒ Array<Vapi::RegexOption>
readonly
These are the options for the regex replacement.
-
#regex ⇒ String
readonly
This is the regex pattern to replace.
-
#value ⇒ String
readonly
This is the value that will replace the match.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::RegexReplacement
Deserialize a JSON object to an instance of RegexReplacement.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(regex:, value:, options: OMIT, additional_properties: nil) ⇒ Vapi::RegexReplacement constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of RegexReplacement to a JSON object.
Constructor Details
#initialize(regex:, value:, options: OMIT, additional_properties: nil) ⇒ Vapi::RegexReplacement
32 33 34 35 36 37 38 39 40 |
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 32 def initialize(regex:, value:, options: OMIT, additional_properties: nil) @regex = regex @options = if != OMIT @value = value @additional_properties = additional_properties @_field_set = { "regex": regex, "options": , "value": value }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
18 19 20 |
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 18 def additional_properties @additional_properties end |
#options ⇒ Array<Vapi::RegexOption> (readonly)
Returns These are the options for the regex replacement. Default all options are disabled. @default [].
14 15 16 |
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 14 def @options end |
#regex ⇒ String (readonly)
Returns This is the regex pattern to replace.
10 11 12 |
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 10 def regex @regex end |
#value ⇒ String (readonly)
Returns This is the value that will replace the match.
16 17 18 |
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 16 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::RegexReplacement
Deserialize a JSON object to an instance of RegexReplacement
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 46 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) regex = parsed_json["regex"] = parsed_json["options"]&.map do |item| item = item.to_json Vapi::RegexOption.from_json(json_object: item) end value = parsed_json["value"] new( regex: regex, options: , value: value, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
76 77 78 79 80 |
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 76 def self.validate_raw(obj:) obj.regex.is_a?(String) != false || raise("Passed value for field obj.regex is not the expected type, validation failed.") obj.&.is_a?(Array) != false || raise("Passed value for field obj.options is not the expected type, validation failed.") obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of RegexReplacement to a JSON object
66 67 68 |
# File 'lib/vapi_server_sdk/types/regex_replacement.rb', line 66 def to_json(*_args) @_field_set&.to_json end |