-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Noel Welsh edited this page Dec 4, 2012
·
10 revisions
This is a Ruby client for the v1 Myna API, using EventMachine for asychronous goodness. Tested in Ruby 1.9.2
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.
If you're not already using EventMachine, you need to start it
Myna.run.getYou 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.stopFor more detail, see:
Find us on #myna on Freenode.
Join the Myna Users group on Google Groups.
Email hello at mynaweb dot com