Class: UspsApi::Dock
- Defined in:
- lib/usps_api/models/dock.rb
Overview
Dock Model.
Instance Attribute Summary collapse
-
#depth ⇒ Integer
The depth of the dock, or distance from the dock doors to the wall which separates the dock from the other sections of the facility (in feet).
-
#height ⇒ Integer
The loading dock height, or distance from the yard surface to the dock surface level (in inches).
-
#width ⇒ Integer
The width of the dock from one end to the other (in feet).
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(width: SKIP, depth: SKIP, height: SKIP, additional_properties: nil) ⇒ Dock
constructor
A new instance of Dock.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(width: SKIP, depth: SKIP, height: SKIP, additional_properties: nil) ⇒ Dock
Returns a new instance of Dock.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/usps_api/models/dock.rb', line 49 def initialize(width: SKIP, depth: SKIP, height: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @width = width unless width == SKIP @depth = depth unless depth == SKIP @height = height unless height == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#depth ⇒ Integer
The depth of the dock, or distance from the dock doors to the wall which separates the dock from the other sections of the facility (in feet).
19 20 21 |
# File 'lib/usps_api/models/dock.rb', line 19 def depth @depth end |
#height ⇒ Integer
The loading dock height, or distance from the yard surface to the dock surface level (in inches).
24 25 26 |
# File 'lib/usps_api/models/dock.rb', line 24 def height @height end |
#width ⇒ Integer
The width of the dock from one end to the other (in feet).
14 15 16 |
# File 'lib/usps_api/models/dock.rb', line 14 def width @width end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/usps_api/models/dock.rb', line 61 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. width = hash.key?('width') ? hash['width'] : SKIP depth = hash.key?('depth') ? hash['depth'] : SKIP height = hash.key?('height') ? hash['height'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. Dock.new(width: width, depth: depth, height: height, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
27 28 29 30 31 32 33 |
# File 'lib/usps_api/models/dock.rb', line 27 def self.names @_hash = {} if @_hash.nil? @_hash['width'] = 'width' @_hash['depth'] = 'depth' @_hash['height'] = 'height' @_hash end |
.nullables ⇒ Object
An array for nullable fields
45 46 47 |
# File 'lib/usps_api/models/dock.rb', line 45 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
36 37 38 39 40 41 42 |
# File 'lib/usps_api/models/dock.rb', line 36 def self.optionals %w[ width depth height ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
91 92 93 94 95 |
# File 'lib/usps_api/models/dock.rb', line 91 def inspect class_name = self.class.name.split('::').last "<#{class_name} width: #{@width.inspect}, depth: #{@depth.inspect}, height:"\ " #{@height.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
84 85 86 87 88 |
# File 'lib/usps_api/models/dock.rb', line 84 def to_s class_name = self.class.name.split('::').last "<#{class_name} width: #{@width}, depth: #{@depth}, height: #{@height},"\ " additional_properties: #{@additional_properties}>" end |