Class: SwaggerPetstoreOpenApi30::Pet
- Defined in:
- lib/swagger_petstore_open_api30/models/pet.rb
Overview
Pet Model.
Instance Attribute Summary collapse
-
#category ⇒ Category
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#name ⇒ String
TODO: Write general description for this method.
-
#photo_urls ⇒ Array[String]
TODO: Write general description for this method.
-
#status ⇒ Status1Enum
pet status in the store.
-
#tags ⇒ Array[Tag]
TODO: Write general description for this method.
Class Method Summary collapse
- .from_element(root) ⇒ Object
-
.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(name = nil, photo_urls = nil, id = SKIP, category = SKIP, tags = SKIP, status = SKIP) ⇒ Pet
constructor
A new instance of Pet.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
- #to_xml_element(doc, root_name) ⇒ 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(name = nil, photo_urls = nil, id = SKIP, category = SKIP, tags = SKIP, status = SKIP) ⇒ Pet
Returns a new instance of Pet.
63 64 65 66 67 68 69 70 71 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 63 def initialize(name = nil, photo_urls = nil, id = SKIP, category = SKIP, = SKIP, status = SKIP) @id = id unless id == SKIP @name = name @category = category unless category == SKIP @photo_urls = photo_urls @tags = unless == SKIP @status = status unless status == SKIP end |
Instance Attribute Details
#category ⇒ Category
TODO: Write general description for this method
22 23 24 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 22 def category @category end |
#id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 14 def id @id end |
#name ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 18 def name @name end |
#photo_urls ⇒ Array[String]
TODO: Write general description for this method
26 27 28 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 26 def photo_urls @photo_urls end |
#status ⇒ Status1Enum
pet status in the store
34 35 36 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 34 def status @status end |
#tags ⇒ Array[Tag]
TODO: Write general description for this method
30 31 32 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 30 def @tags end |
Class Method Details
.from_element(root) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 103 def self.from_element(root) name = XmlUtilities.from_element(root, 'name', String) photo_urls = XmlUtilities.from_element_to_array( root, 'photoUrl', String, wrapping_element_name: 'photoUrls' ) id = XmlUtilities.from_element(root, 'id', Integer) category = XmlUtilities.from_element(root, 'category', Category) = XmlUtilities.from_element_to_array(root, 'tag', Tag, wrapping_element_name: 'tags') status = XmlUtilities.from_element(root, 'status', String) new(name, photo_urls, id, category, , status) end |
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 74 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : nil photo_urls = hash.key?('photoUrls') ? hash['photoUrls'] : nil id = hash.key?('id') ? hash['id'] : SKIP category = Category.from_hash(hash['category']) if hash['category'] # Parameter is an array, so we need to iterate through it = nil unless hash['tags'].nil? = [] hash['tags'].each do |structure| << (Tag.from_hash(structure) if structure) end end = SKIP unless hash.key?('tags') status = hash.key?('status') ? hash['status'] : SKIP # Create object from extracted values. Pet.new(name, photo_urls, id, category, , status) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash['category'] = 'category' @_hash['photo_urls'] = 'photoUrls' @_hash['tags'] = 'tags' @_hash['status'] = 'status' @_hash end |
.nullables ⇒ Object
An array for nullable fields
59 60 61 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 59 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
49 50 51 52 53 54 55 56 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 49 def self.optionals %w[ id category tags status ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
145 146 147 148 149 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 145 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}, category: #{@category.inspect},"\ " photo_urls: #{@photo_urls.inspect}, tags: #{@tags.inspect}, status: #{@status.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
138 139 140 141 142 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 138 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, name: #{@name}, category: #{@category}, photo_urls:"\ " #{@photo_urls}, tags: #{@tags}, status: #{@status}>" end |
#to_xml_element(doc, root_name) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/swagger_petstore_open_api30/models/pet.rb', line 122 def to_xml_element(doc, root_name) root = doc.create_element(root_name) XmlUtilities.add_as_subelement(doc, root, 'name', name) XmlUtilities.add_array_as_subelement(doc, root, 'photoUrl', photo_urls, wrapping_element_name: 'photoUrls') XmlUtilities.add_as_subelement(doc, root, 'id', id) XmlUtilities.add_as_subelement(doc, root, 'category', category) XmlUtilities.add_array_as_subelement(doc, root, 'tag', , wrapping_element_name: 'tags') XmlUtilities.add_as_subelement(doc, root, 'status', status) root end |