Class: Synthra::Types::AddressLocation::Longitude
- Defined in:
- lib/synthra/types/address_location/locations.rb
Overview
Longitude type
Instance Method Summary collapse
- #generate_edge(rng, context, args) ⇒ Object
- #generate_invalid(rng, context, args) ⇒ Object
-
#generate_random(rng, context, args) ⇒ Float
Generate random longitude.
Instance Method Details
#generate_edge(rng, context, args) ⇒ Object
339 340 341 |
# File 'lib/synthra/types/address_location/locations.rb', line 339 def generate_edge(rng, context, args) [-180.0, 180.0, 0.0].sample(random: rng.instance_variable_get(:@random)) end |
#generate_invalid(rng, context, args) ⇒ Object
343 344 345 |
# File 'lib/synthra/types/address_location/locations.rb', line 343 def generate_invalid(rng, context, args) [nil, "not a number", [], {}].sample(random: rng.instance_variable_get(:@random)) end |
#generate_random(rng, context, args) ⇒ Float
Generate random longitude
328 329 330 331 332 333 334 335 336 337 |
# File 'lib/synthra/types/address_location/locations.rb', line 328 def generate_random(rng, context, args) range = args[:range] || (-180.0..180.0) precision = args[:precision] || 6 min = [range.min, -180.0].max max = [range.max, 180.0].min value = rng.rand * (max - min) + min value.round(precision) end |