Class: Forgery::Geo
Overview
Generates random geographic information.
Constant Summary
Constants inherited from Forgery
Class Method Summary collapse
-
.latitude ⇒ Object
Return a latitude in the range -90.0 to +90.0 as a float.
-
.latitude_degrees ⇒ Object
Return a latitude’s degrees component in the range -180 to +180 as an integer.
-
.latitude_direction ⇒ Object
Return a latitude’s direction component, either “N” (north) or “S” (south).
-
.latitude_minutes ⇒ Object
Return a latitude’s minutes component in the range 0 to 60 as an integer.
-
.latitude_seconds ⇒ Object
Return a latitude’s seconds component in the range 0 to 60 as an integer.
-
.longitude ⇒ Object
Return a longitude in the range -180.0 to +180.0 as a float.
-
.longitude_degrees ⇒ Object
Return a longitude’s degrees component in the range -180 to +180 as an integer.
-
.longitude_direction ⇒ Object
Return a longitude’s direction component, either “E” (east) or “W” (west).
-
.longitude_minutes ⇒ Object
Return a longitude’s minutes component in the range 0 to 60 as an integer.
-
.longitude_seconds ⇒ Object
Return a longitude’s seconds component in the range 0 to 60 as an integer.
Methods inherited from Forgery
Extend, dictionaries, formats, load_from!, load_paths, rails?, rails_root
Class Method Details
.latitude ⇒ Object
Return a latitude in the range -90.0 to +90.0 as a float.
5 6 7 |
# File 'lib/forgery/forgery/geo.rb', line 5 def self.latitude rand * 180.0 - 90.0 end |
.latitude_degrees ⇒ Object
Return a latitude’s degrees component in the range -180 to +180 as an integer.
10 11 12 |
# File 'lib/forgery/forgery/geo.rb', line 10 def self.latitude_degrees rand(360)-180 end |
.latitude_direction ⇒ Object
Return a latitude’s direction component, either “N” (north) or “S” (south)
25 26 27 |
# File 'lib/forgery/forgery/geo.rb', line 25 def self.latitude_direction ['N','S'].sample end |
.latitude_minutes ⇒ Object
Return a latitude’s minutes component in the range 0 to 60 as an integer.
15 16 17 |
# File 'lib/forgery/forgery/geo.rb', line 15 def self.latitude_minutes rand(60) end |
.latitude_seconds ⇒ Object
Return a latitude’s seconds component in the range 0 to 60 as an integer.
20 21 22 |
# File 'lib/forgery/forgery/geo.rb', line 20 def self.latitude_seconds rand(60) end |
.longitude ⇒ Object
Return a longitude in the range -180.0 to +180.0 as a float.
30 31 32 |
# File 'lib/forgery/forgery/geo.rb', line 30 def self.longitude rand * 360.0 - 180.0 end |
.longitude_degrees ⇒ Object
Return a longitude’s degrees component in the range -180 to +180 as an integer.
35 36 37 |
# File 'lib/forgery/forgery/geo.rb', line 35 def self.longitude_degrees rand(360)-180 end |
.longitude_direction ⇒ Object
Return a longitude’s direction component, either “E” (east) or “W” (west)
50 51 52 |
# File 'lib/forgery/forgery/geo.rb', line 50 def self.longitude_direction ["E","W"].sample end |
.longitude_minutes ⇒ Object
Return a longitude’s minutes component in the range 0 to 60 as an integer.
40 41 42 |
# File 'lib/forgery/forgery/geo.rb', line 40 def self.longitude_minutes rand(60) end |
.longitude_seconds ⇒ Object
Return a longitude’s seconds component in the range 0 to 60 as an integer.
45 46 47 |
# File 'lib/forgery/forgery/geo.rb', line 45 def self.longitude_seconds rand(60) end |