class OverpassAPI::Base

base class, ql and xml extend this

Constants

DEFAULT_ENDPOINT

Public Class Methods

new(args = {}) click to toggle source
# File lib/base.rb, line 9
def initialize(args = {})
  bbox = args[:bbox]
  bounding_box(bbox[:s], bbox[:n], bbox[:w], bbox[:e]) if bbox

  @endpoint = args[:endpoint] || DEFAULT_ENDPOINT
  @timeout = args[:timeout]
end

Public Instance Methods

bounding_box(south, north, west, east) click to toggle source
# File lib/base.rb, line 17
def bounding_box(south, north, west, east)
  @bbox = "#{south},#{west},#{north},#{east}"
end
query(query) click to toggle source
# File lib/base.rb, line 21
def query(query)
  perform build_query(query)
end
raw_query(query) click to toggle source
# File lib/base.rb, line 25
def raw_query(query)
  perform query
end

Private Instance Methods

perform(query) click to toggle source
# File lib/base.rb, line 31
def perform(query)
  r = HTTPI::Request.new(url: @endpoint, body: query)
  JSON.parse(HTTPI.post(r).body, symbolize_names: true)
end