Class: Verizon::GeoFeature
- Defined in:
- lib/verizon/models/geo_feature.rb
Overview
GeoFeature Model.
Instance Attribute Summary collapse
-
#geometry ⇒ Object
TODO: Write general description for this method.
-
#properties ⇒ Object
TODO: Write general description for this method.
-
#type ⇒ FeatureType
TODO: Write general description for this method.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(type:, geometry:, properties:) ⇒ GeoFeature
constructor
A new instance of GeoFeature.
-
#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(type:, geometry:, properties:) ⇒ GeoFeature
Returns a new instance of GeoFeature.
43 44 45 46 47 |
# File 'lib/verizon/models/geo_feature.rb', line 43 def initialize(type:, geometry:, properties:) @type = type @geometry = geometry @properties = properties end |
Instance Attribute Details
#geometry ⇒ Object
TODO: Write general description for this method
18 19 20 |
# File 'lib/verizon/models/geo_feature.rb', line 18 def geometry @geometry end |
#properties ⇒ Object
TODO: Write general description for this method
22 23 24 |
# File 'lib/verizon/models/geo_feature.rb', line 22 def properties @properties end |
#type ⇒ FeatureType
TODO: Write general description for this method
14 15 16 |
# File 'lib/verizon/models/geo_feature.rb', line 14 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/verizon/models/geo_feature.rb', line 50 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. type = hash.key?('type') ? hash['type'] : nil geometry = hash.key?('geometry') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:Geometry), hash['geometry'] ) : nil properties = hash.key?('properties') ? hash['properties'] : nil # Create object from extracted values. GeoFeature.new(type: type, geometry: geometry, properties: properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 |
# File 'lib/verizon/models/geo_feature.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['type'] = 'type' @_hash['geometry'] = 'geometry' @_hash['properties'] = 'properties' @_hash end |
.nullables ⇒ Object
An array for nullable fields
39 40 41 |
# File 'lib/verizon/models/geo_feature.rb', line 39 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
34 35 36 |
# File 'lib/verizon/models/geo_feature.rb', line 34 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/verizon/models/geo_feature.rb', line 68 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.type, ->(val) { FeatureType.validate(val) }) and UnionTypeLookUp.get(:Geometry) .validate(value.geometry) and APIHelper.valid_type?(value.properties, ->(val) { val.instance_of? Object }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['type'], ->(val) { FeatureType.validate(val) }) and UnionTypeLookUp.get(:Geometry) .validate(value['geometry']) and APIHelper.valid_type?(value['properties'], ->(val) { val.instance_of? Object }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
99 100 101 102 103 |
# File 'lib/verizon/models/geo_feature.rb', line 99 def inspect class_name = self.class.name.split('::').last "<#{class_name} type: #{@type.inspect}, geometry: #{@geometry.inspect}, properties:"\ " #{@properties.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
93 94 95 96 |
# File 'lib/verizon/models/geo_feature.rb', line 93 def to_s class_name = self.class.name.split('::').last "<#{class_name} type: #{@type}, geometry: #{@geometry}, properties: #{@properties}>" end |