Class: GoogleMapsPlatform::DirectionsViaWaypoint

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/google_maps_platform/models/directions_via_waypoint.rb

Overview

DirectionsViaWaypoint Model.

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(location: SKIP, step_index: SKIP, step_interpolation: SKIP, additional_properties: nil) ⇒ DirectionsViaWaypoint

Returns a new instance of DirectionsViaWaypoint.



49
50
51
52
53
54
55
56
57
58
# File 'lib/google_maps_platform/models/directions_via_waypoint.rb', line 49

def initialize(location: SKIP, step_index: SKIP, step_interpolation: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @location = location unless location == SKIP
  @step_index = step_index unless step_index == SKIP
  @step_interpolation = step_interpolation unless step_interpolation == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#locationLatLngLiteral

An object describing a specific location with Latitude and Longitude in decimal degrees.

Returns:



15
16
17
# File 'lib/google_maps_platform/models/directions_via_waypoint.rb', line 15

def location
  @location
end

#step_indexInteger

The index of the step containing the waypoint.

Returns:

  • (Integer)


19
20
21
# File 'lib/google_maps_platform/models/directions_via_waypoint.rb', line 19

def step_index
  @step_index
end

#step_interpolationFloat

The position of the waypoint along the step’s polyline, expressed as a ratio from 0 to 1.

Returns:

  • (Float)


24
25
26
# File 'lib/google_maps_platform/models/directions_via_waypoint.rb', line 24

def step_interpolation
  @step_interpolation
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  location = LatLngLiteral.from_hash(hash['location']) if hash['location']
  step_index = hash.key?('step_index') ? hash['step_index'] : SKIP
  step_interpolation =
    hash.key?('step_interpolation') ? hash['step_interpolation'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  DirectionsViaWaypoint.new(location: location,
                            step_index: step_index,
                            step_interpolation: step_interpolation,
                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
33
# File 'lib/google_maps_platform/models/directions_via_waypoint.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['location'] = 'location'
  @_hash['step_index'] = 'step_index'
  @_hash['step_interpolation'] = 'step_interpolation'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
# File 'lib/google_maps_platform/models/directions_via_waypoint.rb', line 45

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
41
42
# File 'lib/google_maps_platform/models/directions_via_waypoint.rb', line 36

def self.optionals
  %w[
    location
    step_index
    step_interpolation
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



92
93
94
95
96
97
# File 'lib/google_maps_platform/models/directions_via_waypoint.rb', line 92

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} location: #{@location.inspect}, step_index: #{@step_index.inspect},"\
  " step_interpolation: #{@step_interpolation.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



85
86
87
88
89
# File 'lib/google_maps_platform/models/directions_via_waypoint.rb', line 85

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} location: #{@location}, step_index: #{@step_index}, step_interpolation:"\
  " #{@step_interpolation}, additional_properties: #{@additional_properties}>"
end