Class: Geoblacklight::FeatureInfoResponse
- Inherits:
-
Object
- Object
- Geoblacklight::FeatureInfoResponse
- Defined in:
- lib/geoblacklight/wms_layer/feature_info_response.rb
Instance Method Summary collapse
- #check ⇒ Object
- #error? ⇒ Boolean
- #format ⇒ Object
-
#initialize(response) ⇒ FeatureInfoResponse
constructor
A new instance of FeatureInfoResponse.
Constructor Details
#initialize(response) ⇒ FeatureInfoResponse
Returns a new instance of FeatureInfoResponse.
3 4 5 |
# File 'lib/geoblacklight/wms_layer/feature_info_response.rb', line 3 def initialize(response) @response = response end |
Instance Method Details
#check ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/geoblacklight/wms_layer/feature_info_response.rb', line 7 def check if error? @response else format end end |
#error? ⇒ Boolean
27 28 29 30 |
# File 'lib/geoblacklight/wms_layer/feature_info_response.rb', line 27 def error? @response[:error] || @response.headers['content-type'].slice(0, 9) == 'text/xml' end |
#format ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/geoblacklight/wms_layer/feature_info_response.rb', line 15 def format page = Nokogiri::HTML(@response.body) table_values = { values: [] } page.css('th').each do |th| table_values[:values].push([th.text]) end page.css('td').each_with_index do |td, index| table_values[:values][index].push(td.text) unless index >= table_values[:values].count end table_values end |