Class: Verizon::RoadSignID

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/road_sign_id.rb

Overview

It provide a precise location of one or more roadside signs.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(position = nil, view_angle = nil) ⇒ RoadSignID

Returns a new instance of RoadSignID.



41
42
43
44
# File 'lib/verizon/models/road_sign_id.rb', line 41

def initialize(position = nil, view_angle = nil)
  @position = position
  @view_angle = view_angle
end

Instance Attribute Details

#positionPosition

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.

Returns:



16
17
18
# File 'lib/verizon/models/road_sign_id.rb', line 16

def position
  @position
end

#view_angleString

OctetStrings are described as hexadecimal strings, where each octet is represented by two hexadecimal characters.

Returns:

  • (String)


21
22
23
# File 'lib/verizon/models/road_sign_id.rb', line 21

def view_angle
  @view_angle
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/verizon/models/road_sign_id.rb', line 47

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  position = Position.from_hash(hash['position']) if hash['position']
  view_angle = hash.key?('viewAngle') ? hash['viewAngle'] : nil

  # Create object from extracted values.
  RoadSignID.new(position,
                 view_angle)
end

.namesObject

A mapping from model property names to API property names.



24
25
26
27
28
29
# File 'lib/verizon/models/road_sign_id.rb', line 24

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['position'] = 'position'
  @_hash['view_angle'] = 'viewAngle'
  @_hash
end

.nullablesObject

An array for nullable fields



37
38
39
# File 'lib/verizon/models/road_sign_id.rb', line 37

def self.nullables
  []
end

.optionalsObject

An array for optional fields



32
33
34
# File 'lib/verizon/models/road_sign_id.rb', line 32

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (RoadSignID | Hash)

    value against the validation is performed.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/verizon/models/road_sign_id.rb', line 61

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.position,
                            ->(val) { Position.validate(val) },
                            is_model_hash: true) and
        APIHelper.valid_type?(value.view_angle,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['position'],
                          ->(val) { Position.validate(val) },
                          is_model_hash: true) and
      APIHelper.valid_type?(value['viewAngle'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



90
91
92
93
# File 'lib/verizon/models/road_sign_id.rb', line 90

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} position: #{@position.inspect}, view_angle: #{@view_angle.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



84
85
86
87
# File 'lib/verizon/models/road_sign_id.rb', line 84

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} position: #{@position}, view_angle: #{@view_angle}>"
end