4 $:.unshift '../../lib/rb/lib'
7 require 'thrift/protocol/binaryprotocol'
12 port = ARGV[0] || 9090
14 transport = Thrift::BufferedTransport.new(Thrift::Socket.new('localhost', port))
15 protocol = Thrift::BinaryProtocol.new(transport)
16 client = Calculator::Client.new(protocol)
24 print "1+1=", sum, "\n"
27 print "1+4=", sum, "\n"
31 work.op = Operation::SUBTRACT
34 diff = client.calculate(1, work)
35 print "15-10=", diff, "\n"
37 log = client.getStruct(1)
38 print "Log: ", log.value, "\n"
41 work.op = Operation::DIVIDE
44 quot = client.calculate(1, work)
45 puts "Whoa, we can divide by 0 now?"
46 rescue InvalidOperation => io
47 print "InvalidOperation: ", io.why, "\n"
55 rescue Thrift::Exception => tx
56 print 'Thrift::Exception: ', tx.message, "\n"