Sha256: 73d90d4b2c2a51a76677814a8ac3aa949189b80b4874c313d3f415fec5cba18c

Contents?: true

Size: 683 Bytes

Versions: 4

Compression:

Stored size: 683 Bytes

Contents

require 'rest_client'
require 'nokogiri'

module Pandorified
	API_URL = 'http://www.pandorabots.com/pandora/talk-xml'

	class Result
		def initialize(params)
			@xml = Nokogiri::XML(RestClient.post(API_URL, params))
		end

		def status
			@status ||= @xml.xpath('/result/@status').first.value.to_i
		end

		def botid
			@botid ||= @xml.xpath('/result/@botid').first.value
		end

		def custid
			@custid ||= @xml.xpath('/result/@custid').first.value
		end

		def input
			@input ||= @xml.xpath('/result/input').first.text
		end

		def that
			@that ||= @xml.xpath('/result/that').first.text
		end

		def message
			@message ||= @xml.xpath('/result/message').first.text
		end
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pandorified-0.7.1 lib/pandorified/result.rb
pandorified-0.7.0 lib/pandorified/result.rb
pandorified-0.6.0 lib/pandorified/result.rb
pandorified-0.5.0 lib/pandorified/result.rb