Version 4 (modified by bhaley, 15 years ago) (diff) |
---|
Rappture Ruby API
Load the Rappture module
require "Rappture"
Create Rappture I/O object
rp = Rappture.new(path)
- Notes
- path is a Ruby String containing the name of the XML driver file
Get input value
var = rp.get(path)
- Notes
- returns a Ruby String from the interface element path (a Ruby String); use var.to_f or var.to_i or rp.convert() to convert var to a numeric value
Convert value
var = rp.convert(fromVal, toUnits, showUnits")
fromVal is a Ruby String containing a numeric value and optional units, toUnits is a Ruby String containing the name of target units (e.g. "nm"), and showUnits is one of Rappture::UNITS_ON (in which case var is a Ruby String containing the converted numeric value and the new units) or Rappture::UNITS_OFF (in which case var is a Ruby Float, converted to the new units); raises a RuntimeError exception if conversion fails
Put output value
rp.put(path, value, append)
- Notes
- path is the output element name, value is the output value (a Ruby String, Float, or Fixnum), and append is one of Rappture::OVERWRITE or Rappture::APPEND; raises a RuntimeError exception if value is not of the correct type
Progress message
rp.progress(percent, message)
- Notes
- percent is a Ruby numeric value (Float, Int), message is a Ruby String giving the simulation status
XML
var = rp.xml()
- Notes
- returns a Ruby String containing the XML of the rp object; raises a RuntimeError exception if the XML cannot be retrieved
Result
rp.result()
- Notes
- writes the XML of the rp object to disk
Ruby programming references
- http://www.ruby-lang.org/en Main Ruby site
- http://www.rubycentral.com Collection of Ruby projects
- http://www.ruby-doc.org/docs/ProgrammingRuby Cannonical Ruby reference ("The Pickaxe Book")