|
| 1 | +=begin |
| 2 | +-------------------------------------------------------------------------------------------------------------------- |
| 3 | + <copyright company="Aspose" file="RemoveCharactersByCharacterrb.cs"> |
| 4 | + Copyright (c) 2024 Aspose.Cells Cloud |
| 5 | + </copyright> |
| 6 | + <summary> |
| 7 | + Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | + of this software and associated documentation files (the "Software"), to deal |
| 9 | + in the Software without restriction, including without limitation the rights |
| 10 | + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | + copies of the Software, and to permit persons to whom the Software is |
| 12 | + furnished to do so, subject to the following conditions: |
| 13 | +
|
| 14 | + The above copyright notice and this permission notice shall be included in all |
| 15 | + copies or substantial portions of the Software. |
| 16 | +
|
| 17 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | + SOFTWARE. |
| 24 | + </summary> |
| 25 | +-------------------------------------------------------------------------------------------------------------------- |
| 26 | +=end |
| 27 | + |
| 28 | + |
| 29 | +require 'date' |
| 30 | + |
| 31 | +module AsposeCellsCloud |
| 32 | + |
| 33 | + class RemoveCharactersByCharacter |
| 34 | + # |
| 35 | + attr_accessor :remove_text_method |
| 36 | + # |
| 37 | + attr_accessor :remove_characters |
| 38 | + # |
| 39 | + attr_accessor :remove_character_sets_type |
| 40 | + |
| 41 | + # Attribute mapping from ruby-style variable name to JSON key. |
| 42 | + def self.attribute_map |
| 43 | + { |
| 44 | + :'remove_text_method' => :'RemoveTextMethod', |
| 45 | + :'remove_characters' => :'RemoveCharacters', |
| 46 | + :'remove_character_sets_type' => :'RemoveCharacterSetsType' |
| 47 | + } |
| 48 | + end |
| 49 | + |
| 50 | + # Attribute type mapping. |
| 51 | + def self.swagger_types |
| 52 | + { |
| 53 | + :'remove_text_method' => :'String', |
| 54 | + :'remove_characters' => :'Array<String>', |
| 55 | + :'remove_character_sets_type' => :'String' |
| 56 | + } |
| 57 | + end |
| 58 | + |
| 59 | + # Initializes the object |
| 60 | + # @param [Hash] attributes Model attributes in the form of hash |
| 61 | + def initialize(attributes = {}) |
| 62 | + return unless attributes.is_a?(Hash) |
| 63 | + |
| 64 | + # convert string to symbol for hash key |
| 65 | + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} |
| 66 | + |
| 67 | + if attributes.has_key?(:'RemoveTextMethod') |
| 68 | + self.remove_text_method = attributes[:'RemoveTextMethod'] |
| 69 | + end |
| 70 | + if attributes.has_key?(:'RemoveCharacters') |
| 71 | + self.remove_characters = attributes[:'RemoveCharacters'] |
| 72 | + end |
| 73 | + if attributes.has_key?(:'RemoveCharacterSetsType') |
| 74 | + self.remove_character_sets_type = attributes[:'RemoveCharacterSetsType'] |
| 75 | + end |
| 76 | + |
| 77 | + end |
| 78 | + |
| 79 | + # Show invalid properties with the reasons. Usually used together with valid? |
| 80 | + # @return Array for valid properies with the reasons |
| 81 | + def list_invalid_properties |
| 82 | + invalid_properties = Array.new |
| 83 | + if @remove_text_method.nil? |
| 84 | + invalid_properties.push("invalid value for 'remove_text_method', remove_text_method cannot be nil.") |
| 85 | + end |
| 86 | + if @remove_characters.nil? |
| 87 | + invalid_properties.push("invalid value for 'remove_characters', remove_characters cannot be nil.") |
| 88 | + end |
| 89 | + if @remove_character_sets_type.nil? |
| 90 | + invalid_properties.push("invalid value for 'remove_character_sets_type', remove_character_sets_type cannot be nil.") |
| 91 | + end |
| 92 | + |
| 93 | + return invalid_properties |
| 94 | + end |
| 95 | + |
| 96 | + # Check to see if the all the properties in the model are valid |
| 97 | + # @return true if the model is valid |
| 98 | + def valid? |
| 99 | + return false if @remove_text_method.nil? |
| 100 | + return false if @remove_characters.nil? |
| 101 | + return false if @remove_character_sets_type.nil? |
| 102 | + return true |
| 103 | + end |
| 104 | + |
| 105 | + # Checks equality by comparing each attribute. |
| 106 | + # @param [Object] Object to be compared |
| 107 | + def ==(o) |
| 108 | + return true if self.equal?(o) |
| 109 | + self.class == o.class && |
| 110 | + remove_text_method == o.remove_text_method && |
| 111 | + remove_characters == o.remove_characters && |
| 112 | + remove_character_sets_type == o.remove_character_sets_type |
| 113 | + std_dev == o.std_dev |
| 114 | + end |
| 115 | + |
| 116 | + # @see the `==` method |
| 117 | + # @param [Object] Object to be compared |
| 118 | + def eql?(o) |
| 119 | + self == o |
| 120 | + end |
| 121 | + |
| 122 | + # Calculates hash code according to all attributes. |
| 123 | + # @return [Fixnum] Hash code |
| 124 | + def hash |
| 125 | + [ remove_text_method , remove_characters , remove_character_sets_type ].hash |
| 126 | + end |
| 127 | + |
| 128 | + # Builds the object from hash |
| 129 | + # @param [Hash] attributes Model attributes in the form of hash |
| 130 | + # @return [Object] Returns the model itself |
| 131 | + def build_from_hash(attributes) |
| 132 | + return nil unless attributes.is_a?(Hash) |
| 133 | + self.class.swagger_types.each_pair do |key, type| |
| 134 | + if type =~ /\AArray<(.*)>/i |
| 135 | + # check to ensure the input is an array given that the the attribute |
| 136 | + # is documented as an array but the input is not |
| 137 | + if attributes[self.class.attribute_map[key]].is_a?(Array) |
| 138 | + self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) |
| 139 | + end |
| 140 | + elsif !attributes[self.class.attribute_map[key]].nil? |
| 141 | + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) |
| 142 | + end # or else data not found in attributes(hash), not an issue as the data can be optional |
| 143 | + end |
| 144 | + |
| 145 | + self |
| 146 | + end |
| 147 | + |
| 148 | + # Deserializes the data based on type |
| 149 | + # @param string type Data type |
| 150 | + # @param string value Value to be deserialized |
| 151 | + # @return [Object] Deserialized data |
| 152 | + def _deserialize(type, value) |
| 153 | + case type.to_sym |
| 154 | + when :DateTime |
| 155 | + DateTime.parse(value) |
| 156 | + when :Date |
| 157 | + Date.parse(value) |
| 158 | + when :String |
| 159 | + value.to_s |
| 160 | + when :Integer |
| 161 | + value.to_i |
| 162 | + when :Float |
| 163 | + value.to_f |
| 164 | + when :BOOLEAN |
| 165 | + if value.to_s =~ /\A(true|t|yes|y|1)\z/i |
| 166 | + true |
| 167 | + else |
| 168 | + false |
| 169 | + end |
| 170 | + when :Object |
| 171 | + # generic object (usually a Hash), return directly |
| 172 | + value |
| 173 | + when /\AArray<(?<inner_type>.+)>\z/ |
| 174 | + inner_type = Regexp.last_match[:inner_type] |
| 175 | + value.map { |v| _deserialize(inner_type, v) } |
| 176 | + when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ |
| 177 | + k_type = Regexp.last_match[:k_type] |
| 178 | + v_type = Regexp.last_match[:v_type] |
| 179 | + {}.tap do |hash| |
| 180 | + value.each do |k, v| |
| 181 | + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) |
| 182 | + end |
| 183 | + end |
| 184 | + else # model |
| 185 | + temp_model = AsposeCellsCloud.const_get(type).new |
| 186 | + temp_model.build_from_hash(value) |
| 187 | + end |
| 188 | + end |
| 189 | + |
| 190 | + # Returns the string representation of the object |
| 191 | + # @return [String] String presentation of the object |
| 192 | + def to_s |
| 193 | + to_hash.to_s |
| 194 | + end |
| 195 | + |
| 196 | + # to_body is an alias to to_hash (backward compatibility) |
| 197 | + # @return [Hash] Returns the object in the form of hash |
| 198 | + def to_body |
| 199 | + to_hash |
| 200 | + end |
| 201 | + |
| 202 | + # Returns the object in the form of hash |
| 203 | + # @return [Hash] Returns the object in the form of hash |
| 204 | + def to_hash |
| 205 | + hash = {} |
| 206 | + self.class.attribute_map.each_pair do |attr, param| |
| 207 | + value = self.send(attr) |
| 208 | + next if value.nil? |
| 209 | + hash[param] = _to_hash(value) |
| 210 | + end |
| 211 | + hash |
| 212 | + end |
| 213 | + |
| 214 | + # Outputs non-array value in the form of hash |
| 215 | + # For object, use to_hash. Otherwise, just return the value |
| 216 | + # @param [Object] value Any valid value |
| 217 | + # @return [Hash] Returns the value in the form of hash |
| 218 | + def _to_hash(value) |
| 219 | + if value.is_a?(Array) |
| 220 | + value.compact.map{ |v| _to_hash(v) } |
| 221 | + elsif value.is_a?(Hash) |
| 222 | + {}.tap do |hash| |
| 223 | + value.each { |k, v| hash[k] = _to_hash(v) } |
| 224 | + end |
| 225 | + elsif value.respond_to? :to_hash |
| 226 | + value.to_hash |
| 227 | + else |
| 228 | + value |
| 229 | + end |
| 230 | + end |
| 231 | + |
| 232 | + end |
| 233 | + |
| 234 | +end |
0 commit comments