Class: GoogleMapsPlatform::CellTower

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

Overview

Attributes used to describe a cell tower. The following optional fields are not currently used, but may be included if values are available: age, signalStrength, timingAdvance.

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(cell_id:, location_area_code:, mobile_country_code:, mobile_network_code:, age: SKIP, signal_strength: SKIP, timing_advance: SKIP, additional_properties: nil) ⇒ CellTower

Returns a new instance of CellTower.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/google_maps_platform/models/cell_tower.rb', line 76

def initialize(cell_id:, location_area_code:, mobile_country_code:,
               mobile_network_code:, age: SKIP, signal_strength: SKIP,
               timing_advance: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @cell_id = cell_id
  @location_area_code = location_area_code
  @mobile_country_code = mobile_country_code
  @mobile_network_code = mobile_network_code
  @age = age unless age == SKIP
  @signal_strength = signal_strength unless signal_strength == SKIP
  @timing_advance = timing_advance unless timing_advance == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#ageInteger

The number of milliseconds since this cell was primary. If age is 0, the cellId represents a current measurement.

Returns:

  • (Integer)


39
40
41
# File 'lib/google_maps_platform/models/cell_tower.rb', line 39

def age
  @age
end

#cell_idInteger

Unique identifier of the cell. On GSM, this is the Cell ID (CID); CDMA networks use the Base Station ID (BID). WCDMA networks use the UTRAN/GERAN Cell Identity (UC-Id), which is a 32-bit value concatenating the Radio Network Controller (RNC) and Cell ID. Specifying only the 16-bit Cell ID value in WCDMA networks may return inaccurate results.

Returns:

  • (Integer)


20
21
22
# File 'lib/google_maps_platform/models/cell_tower.rb', line 20

def cell_id
  @cell_id
end

#location_area_codeInteger

The Location Area Code (LAC) for GSM and WCDMA networks. The Network ID (NID) for CDMA networks.

Returns:

  • (Integer)


25
26
27
# File 'lib/google_maps_platform/models/cell_tower.rb', line 25

def location_area_code
  @location_area_code
end

#mobile_country_codeInteger

The cell tower’s Mobile Country Code (MCC).

Returns:

  • (Integer)


29
30
31
# File 'lib/google_maps_platform/models/cell_tower.rb', line 29

def mobile_country_code
  @mobile_country_code
end

#mobile_network_codeInteger

The cell tower’s Mobile Network Code. This is the MNC for GSM and WCDMA; CDMA uses the System ID (SID).

Returns:

  • (Integer)


34
35
36
# File 'lib/google_maps_platform/models/cell_tower.rb', line 34

def mobile_network_code
  @mobile_network_code
end

#signal_strengthFloat

Radio signal strength measured in dBm.

Returns:

  • (Float)


43
44
45
# File 'lib/google_maps_platform/models/cell_tower.rb', line 43

def signal_strength
  @signal_strength
end

#timing_advanceFloat

The timing advance value.

Returns:

  • (Float)


47
48
49
# File 'lib/google_maps_platform/models/cell_tower.rb', line 47

def timing_advance
  @timing_advance
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



93
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
# File 'lib/google_maps_platform/models/cell_tower.rb', line 93

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  cell_id = hash.key?('cellId') ? hash['cellId'] : nil
  location_area_code =
    hash.key?('locationAreaCode') ? hash['locationAreaCode'] : nil
  mobile_country_code =
    hash.key?('mobileCountryCode') ? hash['mobileCountryCode'] : nil
  mobile_network_code =
    hash.key?('mobileNetworkCode') ? hash['mobileNetworkCode'] : nil
  age = hash.key?('age') ? hash['age'] : SKIP
  signal_strength =
    hash.key?('signalStrength') ? hash['signalStrength'] : SKIP
  timing_advance = hash.key?('timingAdvance') ? hash['timingAdvance'] : 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.
  CellTower.new(cell_id: cell_id,
                location_area_code: location_area_code,
                mobile_country_code: mobile_country_code,
                mobile_network_code: mobile_network_code,
                age: age,
                signal_strength: signal_strength,
                timing_advance: timing_advance,
                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['cell_id'] = 'cellId'
  @_hash['location_area_code'] = 'locationAreaCode'
  @_hash['mobile_country_code'] = 'mobileCountryCode'
  @_hash['mobile_network_code'] = 'mobileNetworkCode'
  @_hash['age'] = 'age'
  @_hash['signal_strength'] = 'signalStrength'
  @_hash['timing_advance'] = 'timingAdvance'
  @_hash
end

.nullablesObject

An array for nullable fields



72
73
74
# File 'lib/google_maps_platform/models/cell_tower.rb', line 72

def self.nullables
  []
end

.optionalsObject

An array for optional fields



63
64
65
66
67
68
69
# File 'lib/google_maps_platform/models/cell_tower.rb', line 63

def self.optionals
  %w[
    age
    signal_strength
    timing_advance
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



137
138
139
140
141
142
143
144
# File 'lib/google_maps_platform/models/cell_tower.rb', line 137

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} cell_id: #{@cell_id.inspect}, location_area_code:"\
  " #{@location_area_code.inspect}, mobile_country_code: #{@mobile_country_code.inspect},"\
  " mobile_network_code: #{@mobile_network_code.inspect}, age: #{@age.inspect},"\
  " signal_strength: #{@signal_strength.inspect}, timing_advance: #{@timing_advance.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



128
129
130
131
132
133
134
# File 'lib/google_maps_platform/models/cell_tower.rb', line 128

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} cell_id: #{@cell_id}, location_area_code: #{@location_area_code},"\
  " mobile_country_code: #{@mobile_country_code}, mobile_network_code:"\
  " #{@mobile_network_code}, age: #{@age}, signal_strength: #{@signal_strength},"\
  " timing_advance: #{@timing_advance}, additional_properties: #{@additional_properties}>"
end