Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 812 Bytes

README.md

File metadata and controls

38 lines (24 loc) · 812 Bytes

Basic DRb Example

What is DRb?

Distributed Ruby or DRb allows Ruby programs to communicate with each other on the same machine or over a network. DRb uses remote method invocation to pass commands and data between processes.

Rock, paper scissor game tutorial

  1. Open up a new terminal window.

  2. Start the Game server. (View Source)

$ ruby game_server.rb druby://localhost:8787
  1. Open up a second terminal window.

  2. Open an IRB session.

$ irb --prompt simple -I . -r game.rb -r drb/drb
  1. Connect to the Game server and start a new game.
>> game = Game.new
>> game.server_uri = 'druby://localhost:8787'
  1. Play the game against the machine. (View Source)
>> game.play('rock')

#=> "Computer plays Paper - You Lose!"