Class: Forgery::Geo

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

Overview

Generates random geographic information.

Class Method Summary collapse

Class Method Details

.latitudeObject

Return a latitude in the range -90.0 to +90.0 as a float.



7
8
9
# File 'lib/sixarm_ruby_fab/forgery/geo.rb', line 7

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.



12
13
14
# File 'lib/sixarm_ruby_fab/forgery/geo.rb', line 12

def self.latitude_degrees
  rand(360)-180
end

.latitude_directionObject

Return a latitude’s direction component, either “N” (north) or “S” (south)



27
28
29
# File 'lib/sixarm_ruby_fab/forgery/geo.rb', line 27

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.



17
18
19
# File 'lib/sixarm_ruby_fab/forgery/geo.rb', line 17

def self.latitude_minutes
  rand(60)
end

.latitude_secondsObject

Return a latitude’s seconds component in the range 0 to 60 as an integer.



22
23
24
# File 'lib/sixarm_ruby_fab/forgery/geo.rb', line 22

def self.latitude_seconds
  rand(60)
end

.longitudeObject

Return a longitude in the range -180.0 to +180.0 as a float.



32
33
34
# File 'lib/sixarm_ruby_fab/forgery/geo.rb', line 32

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.



37
38
39
# File 'lib/sixarm_ruby_fab/forgery/geo.rb', line 37

def self.longitude_degrees
  rand(360)-180
end

.longitude_directionObject

Return a longitude’s direction component, either “E” (east) or “W” (west)



52
53
54
# File 'lib/sixarm_ruby_fab/forgery/geo.rb', line 52

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.



42
43
44
# File 'lib/sixarm_ruby_fab/forgery/geo.rb', line 42

def self.longitude_minutes
  rand(60)
end

.longitude_secondsObject

Return a longitude’s seconds component in the range 0 to 60 as an integer.



47
48
49
# File 'lib/sixarm_ruby_fab/forgery/geo.rb', line 47

def self.longitude_seconds
  rand(60)
end