# ---------------------------------------------------------------------- # LANGUAGE: Ruby API # ====================================================================== # AUTHOR: Michael McLennan, Purdue University # Copyright (c) 2004-2012 HUBzero Foundation, LLC # # See the file "license.terms" for information on usage and # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. # ====================================================================== language "Ruby" { extension ".rb" command {ruby @tool/@@FILENAME@@ @driver} main {# ---------------------------------------------------------------------- # MAIN PROGRAM - generated by the Rappture Builder # ---------------------------------------------------------------------- require "Rappture" # open the XML file containing the run parameters io = Rappture.new(ARGV[0]) ######################################################### # Get input values from Rappture ######################################################### @@INPUTS@@ ######################################################### # Add your code here for the main body of your program ######################################################### # spit out progress messages as you go along... io.progress(0, "Starting...") io.progress(5, "Loading data...") io.progress(50, "Half-way there") io.progress(100, "Done") ######################################################### # Save output values back to Rappture ######################################################### @@OUTPUTS@@ io.result(0) } input boolean { code "\n# get input value for $path" code "# returns value as string \"yes\" or \"no\"" code "str = io.get(\"$path.current\")" code "$id = (str == \"yes\")" } input image { code "\n# get input value for $path" code "# returns base64-encoded image data" code "$id = io.get(\"$path.current\")" } input number { set units [attr get units] if {$units ne ""} { code "\n# get input value for $path and convert to $units" code "str = io.get(\"$path.current\")" code "$id = io.convert(str, \"$units\", Rappture::UNITS_OFF)" } else { code "\n# get input value for $path" code "$id = io.get(\"$path.current\")" } } input * { code "\n# get input value for $path" code "$id = io.get(\"$path.current\")" } output curve { code "\n# save output value for $path" code "# this shows just one (x,y) point -- modify as needed" code "str = sprintf(\"%g %g\\n\", x, y)" code "io.put(\"$path.component.xy\", str, Rappture::APPEND)" } output histogram { code "\n# save output value for $path" code "# this shows just one point -- modify as needed" code "# (x,h,w) = x-coord, height of bar, and width of bar (optional)" code "str = sprintf(\"%g %g %g\\n\", x, h, w)" code "io.put(\"$path.component.xhw\", str, Rappture::APPEND)" } output image { code "\n# save output value for $path" code "# data should be base64-encoded image data" code "io.put(\"$path.current\", imdata, Rappture::OVERWRITE)" } output * { code "\n# save output value for $path" code "io.put(\"$path.current\",$id, Rappture::OVERWRITE)" } }