Class: Cleverbot::Parser

Inherits:
HTTParty::Parser
  • Object
show all
Defined in:
lib/cleverbot/parser.rb

Overview

Used in Client to parse responses from Cleverbot.com.

Constant Summary collapse

KEYS =

Keys that correspond to the Array that Cleverbot.com returns. They are combined with the Array to form a response Hash.

[
  'message',
  'sessionid',
  'logurl',
  'vText8',
  'vText7',
  'vText6',
  'vText5',
  'vText4',
  'vText3',
  'vText2',
  'prevref',
  nil,
  'emotionalhistory',
  'ttsLocMP3',
  'ttsLocTXT',
  'ttsLocTXT3',
  'ttsText',
  'lineref',
  'lineURL',
  'linePOST',
  'lineChoices',
  'lineChoicesAbbrev',
  'typingData',
  'divert',
]
SupportedFormats =

Formats supported by the parser. Parser handles text/html responses only with #html.

{ 'text/html' => :html }

Instance Method Summary collapse

Instance Method Details

#htmlObject

Splits the body on "\r" and zips the result with KEYS, which is then formed into a Hash.



40
41
42
# File 'lib/cleverbot/parser.rb', line 40

def html
  Hash[KEYS.zip(body.split("\r"))]
end