class SwisstopoReframe::Reframe

Constants

BASE_URL
LOOKUP

Attributes

altitude[W]
easting[W]
format[W]
given[W]
northing[W]
want[W]

Public Instance Methods

altitude(value) click to toggle source
# File lib/swisstopo_reframe.rb, line 45
def altitude(value)
  @altitude = value
end
easting(value) click to toggle source
# File lib/swisstopo_reframe.rb, line 37
def easting(value)
  @easting = value
end
format(value) click to toggle source
# File lib/swisstopo_reframe.rb, line 57
def format(value)
  @format = value
end
given(value) click to toggle source
# File lib/swisstopo_reframe.rb, line 53
def given(value)
  @given = value.to_s.downcase.to_sym
end
need(value) click to toggle source
# File lib/swisstopo_reframe.rb, line 49
def need(value)
  @want = value
end
northing(value) click to toggle source
# File lib/swisstopo_reframe.rb, line 41
def northing(value)
  @northing = value
end
request() click to toggle source
# File lib/swisstopo_reframe.rb, line 61
def request
  uri_string = request_url + '?' + query_string
  uri = URI(uri_string)
  json_string = Net::HTTP.get_response(uri)
  json_string
end

Private Instance Methods

query_string() click to toggle source
# File lib/swisstopo_reframe.rb, line 77
def query_string
  format = @format.nil? ? 'json' : @format
  altitude = @altitude.nil? ? '' : @altitude
  "northing=#{@northing}&easting=#{@easting}&altitude=#{altitude}&format=#{format}"
end
request_url() click to toggle source
# File lib/swisstopo_reframe.rb, line 70
def request_url
  converter = [@given, @want]
  path = LOOKUP[converter]
  raise 'converter not found!' if path.nil?
  BASE_URL + path
end