Class: Forgery::Geo

Inherits:
Forgery show all
Defined in:
lib/forgery/forgery/geo.rb

Overview

Generates random geographic information.

Constant Summary

Constants inherited from Forgery

VERSION

Class Method Summary collapse

Methods inherited from Forgery

Extend, dictionaries, formats, load_from!, load_paths, rails?, rails_root

Class Method Details

.latitudeObject

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_degreesObject

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_directionObject

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_minutesObject

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_secondsObject

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

.longitudeObject

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_degreesObject

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_directionObject

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_minutesObject

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_secondsObject

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