class LibyuiClient::Http::Response

Public Class Methods

new(res) click to toggle source
# File lib/libyui_client/http/response.rb, line 6
def initialize(res)
  @res = res
end

Public Instance Methods

body(regex_filter: {}) click to toggle source
# File lib/libyui_client/http/response.rb, line 10
def body(regex_filter: {})
  result = JSON.parse(@res.body, symbolize_names: true)
  result.select do |widget|
    regex_filter.all? { |key, value| value.match(widget[key.to_sym]) }
  end
rescue JSON::ParserError => e
  LibyuiClient.logger.error("Error while parsing JSON from response:\n"\
"#{e.message}\n#{e.backtrace.inspect}")
end