This is a discussion on Ruby on Rails within the Ruby forums, part of the Web Development category; Installing Ruby and Rails The installation process of Ruby and Rail on Windows, MAC and Linux are discussed detail in ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Installing Ruby and Rails The installation process of Ruby and Rail on Windows, MAC and Linux are discussed detail in the following thread. http://www.discussweb.com/ruby/4012-...s-windows.html thanks |
| Sponsored Links |
| |||
| Getting Started with Ruby Ruby is the language that is going to make everything happen. To work with Ruby, you need a text editor of the kind you already used to get the Ruby on Rails example working, such as word pad (Start➪ Programs➪Accessories➪WordPad) or Notepad (Start➪Programs➪Accessories➪Notepad) in Windows. Each Ruby program should be saved with the extension .rb |
| |||
| Hello World in Ruby To get started with Ruby and make it display a Hello World message, follow these steps:
C:\rubydev>ruby hello.rb Hello World. |
| |||
| Working with Numbers in RUBY To get started with numbers in Ruby, follow these steps:
Quote:
|
| |||
| Working with Strings in Ruby To get started with strings in Ruby, follow these steps:
Quote:
|
| |||
| Ruby’s reserved words:
|
| |||
| Storing Data in Variables - Working with Variables To get started with variables in Ruby, follow these steps:
Quote:
|
| |||
| Creating Constants You can also create constants in Ruby. A constant holds a value that you do not expect to change, such as the value of pi: PI = 3.1415926535 IP_SERVER_SOURCE = “903.111.333.055” IP_SERVER_TARGET = “903.111.333.056” Unlike other languages, Ruby allows you to change the values in constants by assigning a new value to them: CONST = 1 CONST = 2 However, you’ll get a warning each time you do this: constants.rb:2: warning: already initialized constant CONST |
| |||
| Interpolating Variables To get started with interpolating expressions in double-quoted strings in Ruby, follow these steps:
Quote:
|
| |||
| Reading Text To get started reading text in Ruby, follow these steps:
Quote:
|
| |||
| Using Operators To get started using operators in Ruby, follow these steps:
Quote:
|
| |||
| Ruby Operators Ruby Operators Operator Description [ ] Array reference [ ]= Array element set ** Exponentiation ! Not ~ Complement + Unary plus - Minus * Multiply / Divide % Modulo + Plus - Minus >> Right shift << Left shift & Bitwise And ^ Bitwise exclusive Or (Xor) | Regular Or Comparison operators: <= Less than or equal to < Less than > Greater than >= Greater than or equal to Equality and pattern match operators: <=> Less than, equal to, greater than == Equal to === Tests equality in a when clause of a case statement != Not equal to =~ Regular expression pattern match && Logical And || Logical Or .. Inclusive range ... Exclusive range ? Ternary if : Else Assignment = Normal assign %= Modulus and assign /= Divide and assign -= Subtract and assign += Add and assign *= Multiply and assign **= Exponent and assign defined? True if symbol defined not Logical negation and Logical composition or Logical composition Statement modifiers if unless while until begin/end Block expression |
| |||
| Working with Arrays There are plenty of ways to work with data in Ruby. Next up is to store it in arrays. Arrays act as groups of variables, and you can access each variable in an array with an index number. For example, to create an array, you use the [] operator like this: array = [1, 2, 3] This creates an array with three elements, 1, 2, and 3. You access those elements using an array index like this: Quote:
Quote:
Here’s an example: array = [“Hello”, “there”, “sweetie”, 1, 2, 3] This creates an array filled with six elements, three of which are text and three of which are numbers: Quote:
|
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is Ruby for Web? | S.Vinothkumar | Ruby | 6 | 11-20-2007 01:25 AM |
| Installing Ruby and Rails on Windows | prasannavigneshr | Ruby | 2 | 10-03-2007 03:11 AM |
| Ruby on Rails server config | vivekanandan | Ruby | 7 | 08-04-2007 04:02 AM |
| setting up ruby on rails in Fedora core 6 | rgm5 | Ruby | 1 | 04-17-2007 11:42 PM |
| Ruby IDE | drecko | Ruby | 0 | 02-16-2007 12:11 AM |