Sha256: 91548ac72050001909d8a9ef62d64fadaccc93452c714cc19b97193c4689ad29

Contents?: true

Size: 660 Bytes

Versions: 19

Compression:

Stored size: 660 Bytes

Contents

module Geoblacklight
  class FeatureInfoResponse
    def initialize(response)
      @response = response
    end

    def check
      if error?
        @response
      else
        format
      end
    end

    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)
      end
      table_values
    end

    def error?
      @response[:error] ||
        @response.headers['content-type'].slice(0, 9) == 'text/xml'
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
geoblacklight-0.11.1 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.11.0 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.10.2 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.10.1 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.10.0 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.9.2 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.9.1 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.9.0 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.8.0 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.7.1 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.7.0 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.6.2 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.6.1 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.6.0 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.5.1 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.5.0 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.4.2 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.4.1 lib/geoblacklight/wms_layer/feature_info_response.rb
geoblacklight-0.4.0 lib/geoblacklight/wms_layer/feature_info_response.rb