class Geoblacklight::FeatureInfoResponse

Public Class Methods

new(response) click to toggle source
# File lib/geoblacklight/wms_layer/feature_info_response.rb, line 5
def initialize(response)
  @response = response
end

Public Instance Methods

check() click to toggle source
# File lib/geoblacklight/wms_layer/feature_info_response.rb, line 9
def check
  if error?
    @response
  else
    format
  end
end
error?() click to toggle source
# File lib/geoblacklight/wms_layer/feature_info_response.rb, line 29
def error?
  @response[:error] ||
    @response.headers["content-type"].slice(0, 9) == "text/xml"
end
format() click to toggle source
# File lib/geoblacklight/wms_layer/feature_info_response.rb, line 17
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