class DecimalToDegree

Public Class Methods

convert_latitude(input) click to toggle source
# File lib/decimal_to_degree.rb, line 2
def self.convert_latitude(input)
  d = input.to_i
  m = ( (input.to_f - d) * 60).to_i
  compass = input[0] == '-' ? 'S' : 'N'
  return "#{d}°#{m}'#{compass}"
end
convert_longitude(input) click to toggle source
# File lib/decimal_to_degree.rb, line 10
def self.convert_longitude(input)
  d = input.to_i
  m = ( (input.to_f - d) * 60).to_i
  compass = input[0] == '-' ? 'W' : 'E'
  return "#{d}°#{m}'#{compass}"
end