Ruby Hello World Tutorial
Article Metadata
| Getting Started with Ruby > Download and Install > Hello World > Ruby Quick Start | |
This article shows how to write a very basic Ruby on Symbian "Hello World", copy it to the device, and run it. It assumes you've already installed Ruby and the GUI interactive shell on the phone.
Ruby Hello World
A basic Ruby Hello World is shown below. To spice it up, the script also takes a picture immediately after printing HelloWorld to standard IO:
# Takes a picture using phone camera and saves it to the default image location,
# C:\Data\Images\ECamExtImage<X>.jpg where X is a number.
require 'ECamera'
puts "Hello World"
ECamera::snap_still_image
The script should be copied to the device - the easiest way to do this is to connect using your PC suite and copy-paste the file into the phone file system using Windows File explorer. Then start the basic GUI interactive "Front End" shell, navigate to the file in the file system. The shell will then display the text, take a picture, and then exit with the message "Script Finished. Category: Kill Reason 0"
Running scripts on the command line
Advanced users can also run Ruby scripts with a command line:
ruby <script> [arg1, [arg2, […]]],
where script is a full path to Ruby script, and arg1, arg2, … are optional script arguments. In this case, if the script is calling STDIO functions, you will need the Open C/Open C++ component stdioserver_s60_x_x_SS.SIS (you should already have installed this)
Unfortunately, the standard application manager for Symbian and S60 based phones cannot start the application with a command line, and a data-content recognizer for Ruby scripts is not yet available. So, to run Ruby scripts from a command line, you will need an additional application, for example, the alternative text shell eshell, which is available on some Symbian devices in ROM. (There is no standalone installation file for eshell in the public domain however.) A remote PC console (such as HyperTerminal for Windows) could also be used for this purpose with Telnet daemon for Symbian.
Note that this content was originally hosted on the Symbian Foundation developer wiki.
| Getting Started with Ruby > Download and Install > Hello World > Ruby Quick Start | |


(no comments yet)