class ProtonApi::RecommendationConfig
Attributes
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/proton_api/models/recommendation_config.rb, line 34 def self.attribute_map { :'horizon_max' => :'horizon_max', :'dep_min' => :'dep_min', :'inv_max' => :'inv_max', :'inv_min' => :'inv_min', :'recommended_inflation' => :'recommended_inflation', :'horizon_min' => :'horizon_min', :'recommend' => :'recommend', :'dep_max' => :'dep_max' } end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/proton_api/models/recommendation_config.rb, line 63 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'horizon_max') self.horizon_max = attributes[:'horizon_max'] else self.horizon_max = 64 end if attributes.has_key?(:'dep_min') self.dep_min = attributes[:'dep_min'] end if attributes.has_key?(:'inv_max') self.inv_max = attributes[:'inv_max'] end if attributes.has_key?(:'inv_min') self.inv_min = attributes[:'inv_min'] end if attributes.has_key?(:'recommended_inflation') self.recommended_inflation = attributes[:'recommended_inflation'] else self.recommended_inflation = 0.0 end if attributes.has_key?(:'horizon_min') self.horizon_min = attributes[:'horizon_min'] else self.horizon_min = 1 end if attributes.has_key?(:'recommend') self.recommend = attributes[:'recommend'] else self.recommend = true end if attributes.has_key?(:'dep_max') self.dep_max = attributes[:'dep_max'] end end
Attribute type mapping.
# File lib/proton_api/models/recommendation_config.rb, line 48 def self.swagger_types { :'horizon_max' => :'Integer', :'dep_min' => :'Float', :'inv_max' => :'Float', :'inv_min' => :'Float', :'recommended_inflation' => :'Float', :'horizon_min' => :'Integer', :'recommend' => :'BOOLEAN', :'dep_max' => :'Float' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/proton_api/models/recommendation_config.rb, line 230 def ==(o) return true if self.equal?(o) self.class == o.class && horizon_max == o.horizon_max && dep_min == o.dep_min && inv_max == o.inv_max && inv_min == o.inv_min && recommended_inflation == o.recommended_inflation && horizon_min == o.horizon_min && recommend == o.recommend && dep_max == o.dep_max end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/proton_api/models/recommendation_config.rb, line 278 def _deserialize(type, value) case type.to_sym when :DateTime value when :Date value when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = ProtonApi.const_get(type).new temp_model.build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/proton_api/models/recommendation_config.rb, line 342 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/proton_api/models/recommendation_config.rb, line 258 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
Custom attribute writer method with validation @param [Object] dep_max
Value to be assigned
# File lib/proton_api/models/recommendation_config.rb, line 220 def dep_max=(dep_max) if !dep_max.nil? && dep_max < 0 fail ArgumentError, 'invalid value for "dep_max", must be greater than or equal to 0.' end @dep_max = dep_max end
Custom attribute writer method with validation @param [Object] dep_min
Value to be assigned
# File lib/proton_api/models/recommendation_config.rb, line 170 def dep_min=(dep_min) if !dep_min.nil? && dep_min < 0 fail ArgumentError, 'invalid value for "dep_min", must be greater than or equal to 0.' end @dep_min = dep_min end
@see the `==` method @param [Object] Object to be compared
# File lib/proton_api/models/recommendation_config.rb, line 245 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Fixnum] Hash code
# File lib/proton_api/models/recommendation_config.rb, line 251 def hash [horizon_max, dep_min, inv_max, inv_min, recommended_inflation, horizon_min, recommend, dep_max].hash end
Custom attribute writer method with validation @param [Object] horizon_max
Value to be assigned
# File lib/proton_api/models/recommendation_config.rb, line 160 def horizon_max=(horizon_max) if !horizon_max.nil? && horizon_max < 0 fail ArgumentError, 'invalid value for "horizon_max", must be greater than or equal to 0.' end @horizon_max = horizon_max end
Custom attribute writer method with validation @param [Object] horizon_min
Value to be assigned
# File lib/proton_api/models/recommendation_config.rb, line 210 def horizon_min=(horizon_min) if !horizon_min.nil? && horizon_min < 0 fail ArgumentError, 'invalid value for "horizon_min", must be greater than or equal to 0.' end @horizon_min = horizon_min end
Custom attribute writer method with validation @param [Object] inv_max
Value to be assigned
# File lib/proton_api/models/recommendation_config.rb, line 180 def inv_max=(inv_max) if !inv_max.nil? && inv_max < 0 fail ArgumentError, 'invalid value for "inv_max", must be greater than or equal to 0.' end @inv_max = inv_max end
Custom attribute writer method with validation @param [Object] inv_min
Value to be assigned
# File lib/proton_api/models/recommendation_config.rb, line 190 def inv_min=(inv_min) if !inv_min.nil? && inv_min < 0 fail ArgumentError, 'invalid value for "inv_min", must be greater than or equal to 0.' end @inv_min = inv_min end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/proton_api/models/recommendation_config.rb, line 112 def list_invalid_properties invalid_properties = Array.new if !@horizon_max.nil? && @horizon_max < 0 invalid_properties.push('invalid value for "horizon_max", must be greater than or equal to 0.') end if !@dep_min.nil? && @dep_min < 0 invalid_properties.push('invalid value for "dep_min", must be greater than or equal to 0.') end if !@inv_max.nil? && @inv_max < 0 invalid_properties.push('invalid value for "inv_max", must be greater than or equal to 0.') end if !@inv_min.nil? && @inv_min < 0 invalid_properties.push('invalid value for "inv_min", must be greater than or equal to 0.') end if !@recommended_inflation.nil? && @recommended_inflation < -1 invalid_properties.push('invalid value for "recommended_inflation", must be greater than or equal to -1.') end if !@horizon_min.nil? && @horizon_min < 0 invalid_properties.push('invalid value for "horizon_min", must be greater than or equal to 0.') end if !@dep_max.nil? && @dep_max < 0 invalid_properties.push('invalid value for "dep_max", must be greater than or equal to 0.') end invalid_properties end
Custom attribute writer method with validation @param [Object] recommended_inflation
Value to be assigned
# File lib/proton_api/models/recommendation_config.rb, line 200 def recommended_inflation=(recommended_inflation) if !recommended_inflation.nil? && recommended_inflation < -1 fail ArgumentError, 'invalid value for "recommended_inflation", must be greater than or equal to -1.' end @recommended_inflation = recommended_inflation end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/proton_api/models/recommendation_config.rb, line 329 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/proton_api/models/recommendation_config.rb, line 317 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/proton_api/models/recommendation_config.rb, line 147 def valid? return false if !@horizon_max.nil? && @horizon_max < 0 return false if !@dep_min.nil? && @dep_min < 0 return false if !@inv_max.nil? && @inv_max < 0 return false if !@inv_min.nil? && @inv_min < 0 return false if !@recommended_inflation.nil? && @recommended_inflation < -1 return false if !@horizon_min.nil? && @horizon_min < 0 return false if !@dep_max.nil? && @dep_max < 0 true end