You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pbosetti edited this page Sep 28, 2011
·
1 revision
Ruby client library
To use the library from within your Ruby script, do as follows:
#require 'charter-client'
# Instantiate a new Charter::Client object:
ch = Charter::Client.new(1) # 1 is the default ID
# Clear the buffer
ch.clear
200.times do |i|
# Use the 's' mode:
# send an array like [x, y1, y2, y3]
ch << [i/10.0, Math::sin(i/10.0), 1.1*Math::cos(i/10.0), 0.7*Math::sin(i/10.0)+rand*0.05]
end
ch.names %w|speed velocity acceleration|
sleep 5
200.times do |i|
# alternatively, use the 'm' mode:
# send an array like [[x1, y1], [x2, y2]]
ch << [ [i/10.0, rand], [i/10.0+rand*0.01, rand] ]
end
# close the connection, forcing Charter to stop updating the charts:
ch.close