Class: Ogc::WebFeatureService::Base
- Inherits:
-
Object
- Object
- Ogc::WebFeatureService::Base
- Includes:
- Exceptions
- Defined in:
- lib/ogc/web_feature_service/base.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_PARAMS =
{ 'service' => 'wfs' }.freeze
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #get(extra_params, &block) ⇒ Object
- #http ⇒ Object
-
#initialize(url, params = nil) ⇒ Base
constructor
A new instance of Base.
- #post(body, &block) ⇒ Object
Constructor Details
#initialize(url, params = nil) ⇒ Base
Returns a new instance of Base.
27 28 29 30 |
# File 'lib/ogc/web_feature_service/base.rb', line 27 def initialize(url, params = nil) @url = url @params = (params ? params.stringify_keys : {}).merge!(DEFAULT_PARAMS) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
17 18 19 |
# File 'lib/ogc/web_feature_service/base.rb', line 17 def params @params end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
17 18 19 |
# File 'lib/ogc/web_feature_service/base.rb', line 17 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
17 18 19 |
# File 'lib/ogc/web_feature_service/base.rb', line 17 def url @url end |
Class Method Details
.request_name ⇒ Object
22 23 24 |
# File 'lib/ogc/web_feature_service/base.rb', line 22 def request_name @request_name ||= to_s.demodulize end |
Instance Method Details
#get(extra_params, &block) ⇒ Object
32 33 34 35 |
# File 'lib/ogc/web_feature_service/base.rb', line 32 def get(extra_params, &block) params = extra_params ? extra_params.merge(@params) : @params fetch(:get, params, &block) end |
#http ⇒ Object
41 42 43 |
# File 'lib/ogc/web_feature_service/base.rb', line 41 def http @http ||= Net::HTTP.new(uri.host, uri.port) end |
#post(body, &block) ⇒ Object
37 38 39 |
# File 'lib/ogc/web_feature_service/base.rb', line 37 def post(body, &block) fetch(:post, body.respond_to?(:to_xml) ? body.to_xml : body, &block) end |