Class: Verizon::Position
- Defined in:
- lib/verizon/models/position.rb
Overview
It provides a precise location in the WGS-84 coordinate system, from which short offsets may be used to create additional data using a flat earth projection centered on this location.
Instance Attribute Summary collapse
-
#lat ⇒ Integer
The geographic latitude of an object, expressed in 1/10th integer microdegrees, as a 31 bit value, and with reference to the horizontal datum then in use.
-
#long ⇒ Integer
The geographic longitude of an object, expressed in 1/10th integer microdegrees, as a 32-bit value, and with reference to the horizontal datum then in use.
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(lat:, long:) ⇒ Position
constructor
A new instance of Position.
-
#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(lat:, long:) ⇒ Position
Returns a new instance of Position.
44 45 46 47 |
# File 'lib/verizon/models/position.rb', line 44 def initialize(lat:, long:) @lat = lat @long = long end |
Instance Attribute Details
#lat ⇒ Integer
The geographic latitude of an object, expressed in 1/10th integer microdegrees, as a 31 bit value, and with reference to the horizontal datum then in use. The value 900000001 shall be used when unavailable.
18 19 20 |
# File 'lib/verizon/models/position.rb', line 18 def lat @lat end |
#long ⇒ Integer
The geographic longitude of an object, expressed in 1/10th integer microdegrees, as a 32-bit value, and with reference to the horizontal datum then in use. The value 1800000001 shall be used when unavailable.
24 25 26 |
# File 'lib/verizon/models/position.rb', line 24 def long @long 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 |
# File 'lib/verizon/models/position.rb', line 50 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. lat = hash.key?('lat') ? hash['lat'] : nil long = hash.key?('long') ? hash['long'] : nil # Create object from extracted values. Position.new(lat: lat, long: long) end |
.names ⇒ Object
A mapping from model property names to API property names.
27 28 29 30 31 32 |
# File 'lib/verizon/models/position.rb', line 27 def self.names @_hash = {} if @_hash.nil? @_hash['lat'] = 'lat' @_hash['long'] = 'long' @_hash end |
.nullables ⇒ Object
An array for nullable fields
40 41 42 |
# File 'lib/verizon/models/position.rb', line 40 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 |
# File 'lib/verizon/models/position.rb', line 35 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/verizon/models/position.rb', line 64 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.lat, ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.long, ->(val) { val.instance_of? Integer }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['lat'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['long'], ->(val) { val.instance_of? Integer }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
91 92 93 94 |
# File 'lib/verizon/models/position.rb', line 91 def inspect class_name = self.class.name.split('::').last "<#{class_name} lat: #{@lat.inspect}, long: #{@long.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
85 86 87 88 |
# File 'lib/verizon/models/position.rb', line 85 def to_s class_name = self.class.name.split('::').last "<#{class_name} lat: #{@lat}, long: #{@long}>" end |