Class: XRBP::WebSocket::Plugins::ResultParser

Inherits:
ResultParserBase show all
Defined in:
lib/xrbp/websocket/plugins/result_parser.rb

Overview

Plugin to automatically parse and convert websocket results, before returning.

Examples:

parse json

connection = WebClient::Connection.new "wss://s1.ripple.com:443"
connection.add_plugin :command_dispatcher, :result_parser

connection.parse_results do |res|
  JSON.parse(res)
end

puts connection.cmd(WebSocket::Cmds::ServerInfo.new)["result"]["info"]["build_version"]

Instance Attribute Summary

Attributes inherited from ResultParserBase

#parser

Attributes inherited from PluginBase

#connection

Instance Method Summary collapse

Methods inherited from ResultParserBase

#added, #parse_result

Methods inherited from PluginBase

#initialize

Constructor Details

This class inherits a constructor from XRBP::PluginBase

Instance Method Details

#parser=(p) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/xrbp/websocket/plugins/result_parser.rb', line 17

def parser=(p)
  super(p)

  self.connection.connections.each { |conn|
    conn.parse_results &p
  } if self.connection.kind_of?(MultiConnection)

  p
end