Sha256: 978b11bd03a4cbe874ced26a77242ef2396385c8d4a1848f8c15bb091121ddc1

Contents?: true

Size: 873 Bytes

Versions: 2

Compression:

Stored size: 873 Bytes

Contents

# Author::        Christopher Brito (cbrito@gmail.com)
# Original Repo:: https://github.com/cbrito/splunk-client

require 'rubygems'
require 'nokogiri'
require File.expand_path File.join(File.dirname(__FILE__), 'splunk_result')

# Simplify the calling of single result data from xpaths into an objects
class SplunkResults
  attr_reader :results

  def initialize(rawResults)
    @results = Array.new

    return @results if rawResults.strip.empty?

    nokoResults = Nokogiri::Slop(rawResults)

    if nokoResults.results.result.respond_to?("length")
      # Multiple Results, build array
      nokoResults.results.result.each do |resultObj|
        @results.push SplunkResult.new(resultObj)
      end
    else
      # Single results object
      @results.push SplunkResult.new(nokoResults.results.result)
    end
    
    return @results
  end
  
end #class SplunkResults

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
splunk-client-0.8.0 lib/splunk_client/splunk_results.rb
splunk-client-0.7.0 lib/splunk_client/splunk_results.rb