Class: Ogc::AbstractBase

Inherits:
Object
  • Object
show all
Includes:
Errors
Defined in:
lib/ogc/abstract_base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, params = nil) ⇒ AbstractBase

Returns a new instance of AbstractBase.



24
25
26
27
28
# File 'lib/ogc/abstract_base.rb', line 24

def initialize(url, params = nil)
  @url    = url
  @params = params.is_a?(Hash) ? params.stringify_keys : {}
  @params.merge!(default_params) if default_params.is_a?(Hash)
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



14
15
16
# File 'lib/ogc/abstract_base.rb', line 14

def params
  @params
end

#responseObject (readonly)

Returns the value of attribute response.



14
15
16
# File 'lib/ogc/abstract_base.rb', line 14

def response
  @response
end

#urlObject (readonly)

Returns the value of attribute url.



14
15
16
# File 'lib/ogc/abstract_base.rb', line 14

def url
  @url
end

Class Method Details

.request_nameObject



19
20
21
# File 'lib/ogc/abstract_base.rb', line 19

def request_name
  @request_name ||= to_s.demodulize
end

Instance Method Details

#get(extra_params, &block) ⇒ Object



30
31
32
33
# File 'lib/ogc/abstract_base.rb', line 30

def get(extra_params, &block)
  params = extra_params ? extra_params.merge(@params) : @params
  fetch(:get, params, &block)
end

#httpObject



39
40
41
# File 'lib/ogc/abstract_base.rb', line 39

def http
  @http ||= Net::HTTP.new(uri.host, uri.port)
end

#post(body, &block) ⇒ Object



35
36
37
# File 'lib/ogc/abstract_base.rb', line 35

def post(body, &block)
  fetch(:post, body.respond_to?(:to_xml) ? body.to_xml : body, &block)
end