Home - myna/ruby-eventmachine-client GitHub Wiki
Myna Ruby/EventMachine Client
This is a Ruby client for the v1 Myna API, using EventMachine for asychronous goodness. Tested in Ruby 1.9.2
Installation
The package is available via RubyGems and can be installed in the usual way:
gem install myna_eventmachine
See Rails for specific details on running in Rails.
Usage
If you're not already using EventMachine, you need to start it
Myna.run.get
You can get a suggestion from Myna without authorizing:
expt = Myna.experiment('45923780-80ed-47c6-aa46-15e2ae7a0e8c')
suggestion = expt.suggest.get
# suggestion has two attributes: choice and token
# suggestion.choice is a string, the choice made by Myna
# suggestion.token is a string, the token you send back to Myna when you reward
puts("Choice is #{suggestion.choice}")
expt.reward(suggestion.token, 1.0)
To create an experiment, add and delete variants, and so on, you must authorize first:
myna = Myna.authorize('email', 'password')
# Create an experiment
expt = myna.create('My funky new experiment').get
expt.create_variant('My new variant')
expt.create_variant('My other new variant')
When you've finished with Myna you might want to stop EventMachine, though this is entirely optional
Myna.stop
For more detail, see:
Getting Help
Find us on #myna on Freenode.
Join the Myna Users group on Google Groups.
Email hello at mynaweb dot com