Class: GoogleMapsPlatform::DirectionsTransitLine
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- GoogleMapsPlatform::DirectionsTransitLine
- Defined in:
- lib/google_maps_platform/models/directions_transit_line.rb
Overview
DirectionsTransitLine Model.
Instance Attribute Summary collapse
-
#agencies ⇒ Array[DirectionsTransitAgency]
The transit agency (or agencies) that operates this transit line.
-
#color ⇒ String
The color commonly used in signage for this line.
-
#icon ⇒ String
Contains the URL for the icon associated with this line.
-
#name ⇒ String
The full name of this transit line, e.g.
-
#short_name ⇒ String
The short name of this transit line.
-
#text_color ⇒ String
The color commonly used in signage for this line.
-
#url ⇒ String
Contains the URL for this transit line as provided by the transit agency.
-
#vehicle ⇒ DirectionsTransitVehicle
Contains the URL for the icon associated with this line.
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.
Instance Method Summary collapse
-
#initialize(agencies:, name:, color: SKIP, short_name: SKIP, text_color: SKIP, url: SKIP, icon: SKIP, vehicle: SKIP, additional_properties: nil) ⇒ DirectionsTransitLine
constructor
A new instance of DirectionsTransitLine.
-
#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(agencies:, name:, color: SKIP, short_name: SKIP, text_color: SKIP, url: SKIP, icon: SKIP, vehicle: SKIP, additional_properties: nil) ⇒ DirectionsTransitLine
Returns a new instance of DirectionsTransitLine.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 76 def initialize(agencies:, name:, color: SKIP, short_name: SKIP, text_color: SKIP, url: SKIP, icon: SKIP, vehicle: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @agencies = agencies @color = color unless color == SKIP @name = name @short_name = short_name unless short_name == SKIP @text_color = text_color unless text_color == SKIP @url = url unless url == SKIP @icon = icon unless icon == SKIP @vehicle = vehicle unless vehicle == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#agencies ⇒ Array[DirectionsTransitAgency]
The transit agency (or agencies) that operates this transit line.
14 15 16 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 14 def agencies @agencies end |
#color ⇒ String
The color commonly used in signage for this line.
18 19 20 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 18 def color @color end |
#icon ⇒ String
Contains the URL for the icon associated with this line.
39 40 41 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 39 def icon @icon end |
#name ⇒ String
The full name of this transit line, e.g. “8 Avenue Local”.
22 23 24 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 22 def name @name end |
#short_name ⇒ String
The short name of this transit line. This will normally be a line number, such as “M7” or “355”.
27 28 29 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 27 def short_name @short_name end |
#text_color ⇒ String
The color commonly used in signage for this line.
31 32 33 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 31 def text_color @text_color end |
#url ⇒ String
Contains the URL for this transit line as provided by the transit agency.
35 36 37 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 35 def url @url end |
#vehicle ⇒ DirectionsTransitVehicle
Contains the URL for the icon associated with this line.
43 44 45 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 43 def vehicle @vehicle end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 94 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it agencies = nil unless hash['agencies'].nil? agencies = [] hash['agencies'].each do |structure| agencies << (DirectionsTransitAgency.from_hash(structure) if structure) end end agencies = nil unless hash.key?('agencies') name = hash.key?('name') ? hash['name'] : nil color = hash.key?('color') ? hash['color'] : SKIP short_name = hash.key?('short_name') ? hash['short_name'] : SKIP text_color = hash.key?('text_color') ? hash['text_color'] : SKIP url = hash.key?('url') ? hash['url'] : SKIP icon = hash.key?('icon') ? hash['icon'] : SKIP vehicle = DirectionsTransitVehicle.from_hash(hash['vehicle']) if hash['vehicle'] # 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. DirectionsTransitLine.new(agencies: agencies, name: name, color: color, short_name: short_name, text_color: text_color, url: url, icon: icon, vehicle: vehicle, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 46 def self.names @_hash = {} if @_hash.nil? @_hash['agencies'] = 'agencies' @_hash['color'] = 'color' @_hash['name'] = 'name' @_hash['short_name'] = 'short_name' @_hash['text_color'] = 'text_color' @_hash['url'] = 'url' @_hash['icon'] = 'icon' @_hash['vehicle'] = 'vehicle' @_hash end |
.nullables ⇒ Object
An array for nullable fields
72 73 74 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 72 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 60 def self.optionals %w[ color short_name text_color url icon vehicle ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
144 145 146 147 148 149 150 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 144 def inspect class_name = self.class.name.split('::').last "<#{class_name} agencies: #{@agencies.inspect}, color: #{@color.inspect}, name:"\ " #{@name.inspect}, short_name: #{@short_name.inspect}, text_color: #{@text_color.inspect},"\ " url: #{@url.inspect}, icon: #{@icon.inspect}, vehicle: #{@vehicle.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
136 137 138 139 140 141 |
# File 'lib/google_maps_platform/models/directions_transit_line.rb', line 136 def to_s class_name = self.class.name.split('::').last "<#{class_name} agencies: #{@agencies}, color: #{@color}, name: #{@name}, short_name:"\ " #{@short_name}, text_color: #{@text_color}, url: #{@url}, icon: #{@icon}, vehicle:"\ " #{@vehicle}, additional_properties: #{@additional_properties}>" end |