source: trunk/builder/scripts/templates/ruby.tl @ 3636

Last change on this file since 3636 was 3636, checked in by mmc, 11 years ago

Fixed the drawing widget to handle notifications from outside widgets, so
that canvas items react to value changes. Also added tooltips for drawing
items.

Nudged the next/back buttons for the pager in a bit, so they're a little
easier to press in the iPad app.

Fixed the Ruby template for the builder to include the overwrite/append flag.

File size: 3.1 KB
Line 
1# ----------------------------------------------------------------------
2#  LANGUAGE:  Ruby API
3# ======================================================================
4#  AUTHOR:  Michael McLennan, Purdue University
5#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
6#
7#  See the file "license.terms" for information on usage and
8#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9# ======================================================================
10language "Ruby" {
11  extension ".rb"
12  command {ruby @tool/@@FILENAME@@ @driver}
13
14  main {# ----------------------------------------------------------------------
15#  MAIN PROGRAM - generated by the Rappture Builder
16# ----------------------------------------------------------------------
17require "Rappture"
18
19# open the XML file containing the run parameters
20io = Rappture.new(ARGV[0])
21
22#########################################################
23# Get input values from Rappture
24#########################################################
25@@INPUTS@@
26
27#########################################################
28#  Add your code here for the main body of your program
29#########################################################
30
31# spit out progress messages as you go along...
32io.progress(0, "Starting...")
33io.progress(5, "Loading data...")
34io.progress(50, "Half-way there")
35io.progress(100, "Done")
36
37#########################################################
38# Save output values back to Rappture
39#########################################################
40@@OUTPUTS@@
41
42io.result(0)
43}
44
45  input boolean {
46    code "\n# get input value for $path"
47    code "# returns value as string \"yes\" or \"no\""
48    code "str = io.get(\"$path.current\")"
49    code "$id = (str == \"yes\")"
50  }
51  input image {
52    code "\n# get input value for $path"
53    code "# returns base64-encoded image data"
54    code "$id = io.get(\"$path.current\")"
55  }
56  input number {
57    set units [attr get units]
58    if {$units ne ""} {
59      code "\n# get input value for $path and convert to $units"
60      code "str = io.get(\"$path.current\")"
61      code "$id = io.convert(str, \"$units\", Rappture::UNITS_OFF)"
62    } else {
63      code "\n# get input value for $path"
64      code "$id = io.get(\"$path.current\")"
65    }
66  }
67  input * {
68    code "\n# get input value for $path"
69    code "$id = io.get(\"$path.current\")"
70  }
71
72  output curve {
73    code "\n# save output value for $path"
74    code "# this shows just one (x,y) point -- modify as needed"
75    code "str = sprintf(\"%g %g\\n\", x, y)"
76    code "io.put(\"$path.component.xy\", str, Rappture::APPEND)"
77  }
78  output histogram {
79    code "\n# save output value for $path"
80    code "# this shows just one point -- modify as needed"
81    code "# (x,h,w) = x-coord, height of bar, and width of bar (optional)"
82    code "str = sprintf(\"%g %g %g\\n\", x, h, w)"
83    code "io.put(\"$path.component.xhw\", str, Rappture::APPEND)"
84  }
85  output image {
86    code "\n# save output value for $path"
87    code "# data should be base64-encoded image data"
88    code "io.put(\"$path.current\", imdata, Rappture::OVERWRITE)"
89  }
90  output * {
91    code "\n# save output value for $path"
92    code "io.put(\"$path.current\",$id, Rappture::OVERWRITE)"
93  }
94}
Note: See TracBrowser for help on using the repository browser.