class ArcREST::Server

superclass

Constants

BAD_ENDPOINT
ENDPOINT_REGEX

Attributes

json[R]
url[R]
version[R]

Public Class Methods

new(url, headers = {}) click to toggle source
# File lib/arcrest/server.rb, line 19
def initialize(url, headers = {})
  @url = url
  @headers = headers
  validate_endpoint_url
  @server_url = server_url
  @json = json_
  @version = version_
end

Protected Instance Methods

add_json_param_to(hash) click to toggle source
# File lib/arcrest/server.rb, line 50
def add_json_param_to(hash)
  { f: 'json' }.merge(hash)
end
get(url, options = {}) click to toggle source
# File lib/arcrest/server.rb, line 54
def get(url, options = {})
  curl_get(query_string(url, options), @headers)
end
json_() click to toggle source
# File lib/arcrest/server.rb, line 34
def json_
  parse_json
end
parse_json(url = @server_url, options = {}) click to toggle source
# File lib/arcrest/server.rb, line 42
def parse_json(url = @server_url, options = {})
  JSON.parse get(url, options)
end
query_string(url, options) click to toggle source
# File lib/arcrest/server.rb, line 58
def query_string(url, options)
  "#{url}?#{URI.encode_www_form(add_json_param_to(options))}"
end
server_url() click to toggle source
# File lib/arcrest/server.rb, line 30
def server_url
  @url[-1] == '/' ? @url[0..-2] : @url
end
validate_endpoint_url() click to toggle source
# File lib/arcrest/server.rb, line 46
def validate_endpoint_url
  raise ArgumentError, BAD_ENDPOINT unless @url =~ ENDPOINT_REGEX
end
version_() click to toggle source
# File lib/arcrest/server.rb, line 38
def version_
  parse_json['currentVersion'] # subclasses use server uri
end