Class: Verizon::EtxGeofence
- Defined in:
- lib/verizon/models/etx_geofence.rb
Overview
The GeoJSON representation of geofence. Geofence supports the following geometry types: LineString, Polygon, MultiLineString, and MultiPolygon. The system only supports a single Feature in the FeatureCollection, so only one Line, Polygon, MultiLine or MultiPolygon can be defined within one Geofencing configuration.
Instance Attribute Summary collapse
-
#features ⇒ Array[GeoFeature]
TODO: Write general description for this method.
-
#type ⇒ FeatureCollectionType
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:, features:) ⇒ EtxGeofence
constructor
A new instance of EtxGeofence.
-
#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:, features:) ⇒ EtxGeofence
Returns a new instance of EtxGeofence.
42 43 44 45 |
# File 'lib/verizon/models/etx_geofence.rb', line 42 def initialize(type:, features:) @type = type @features = features end |
Instance Attribute Details
#features ⇒ Array[GeoFeature]
TODO: Write general description for this method
22 23 24 |
# File 'lib/verizon/models/etx_geofence.rb', line 22 def features @features end |
#type ⇒ FeatureCollectionType
TODO: Write general description for this method
18 19 20 |
# File 'lib/verizon/models/etx_geofence.rb', line 18 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/verizon/models/etx_geofence.rb', line 48 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. type = hash.key?('type') ? hash['type'] : nil # Parameter is an array, so we need to iterate through it features = nil unless hash['features'].nil? features = [] hash['features'].each do |structure| features << (GeoFeature.from_hash(structure) if structure) end end features = nil unless hash.key?('features') # Create object from extracted values. EtxGeofence.new(type: type, features: features) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 |
# File 'lib/verizon/models/etx_geofence.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['type'] = 'type' @_hash['features'] = 'features' @_hash end |
.nullables ⇒ Object
An array for nullable fields
38 39 40 |
# File 'lib/verizon/models/etx_geofence.rb', line 38 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
33 34 35 |
# File 'lib/verizon/models/etx_geofence.rb', line 33 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/verizon/models/etx_geofence.rb', line 71 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.type, ->(val) { FeatureCollectionType.validate(val) }) and APIHelper.valid_type?(value.features, ->(val) { GeoFeature.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['type'], ->(val) { FeatureCollectionType.validate(val) }) and APIHelper.valid_type?(value['features'], ->(val) { GeoFeature.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
102 103 104 105 |
# File 'lib/verizon/models/etx_geofence.rb', line 102 def inspect class_name = self.class.name.split('::').last "<#{class_name} type: #{@type.inspect}, features: #{@features.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
96 97 98 99 |
# File 'lib/verizon/models/etx_geofence.rb', line 96 def to_s class_name = self.class.name.split('::').last "<#{class_name} type: #{@type}, features: #{@features}>" end |