Sha256: 851d09d0bf4102574f3342e2e638ce34c7e678ac8e7d920815a4080375f38040
Contents?: true
Size: 1.09 KB
Versions: 5
Compression:
Stored size: 1.09 KB
Contents
# Author:: Christopher Brito (cbrito@gmail.com) # Original Repo:: https://github.com/cbrito/splunk-client # Simplify the calling of single result data from xpaths into an object # http://stackoverflow.com/questions/2240535/how-do-i-use-hash-keys-as-methods-on-a-class class SplunkResult def initialize(nokogiriNode) @result = nokogiriNode end # Ex: splunkResult.time => nokogiriNode.result.field("[@k=\"_time\"]").value.text def time @result.field("[@k=\"_time\"]").value.text end # Ex: splunkResult.raw => nokogiriNode.result.field("[@k=\"_raw\"]").v.text def raw @result.field("[@k=\"_raw\"]").v.text end # Ex: splunkResult.sourceIp => nokogiriNode.field("[@k=\"sourceIp\"]").value.text def method_missing(name, *args, &blk) if args.empty? && blk.nil? && @result.field("[@k=\"#{name}\"]") @result.field("[@k=\"#{name}\"]").value.text else super end end def respond_to?(name) begin unless @result.field("[@k=\"#{name}\"]").nil? then true else super end rescue NoMethodError super end end end #class SplunkResult
Version data entries
5 entries across 5 versions & 1 rubygems