Read Chris Pines Tutorial and put this cheat sheet together for myself.
==== Ruby for VB Programmers ====
--- Variables ---
All variables are variant objects.
Variables do not have to be declared before use.
Variables are not formally declared. (No Dim statement).
As variants they may be re-assigned any data type at any time.
Variables that are assigned strings or numbers have methods. (As in VB.NET).
Variables that are spelled the same but with different letter case ARE BY DEFINITION different variables.
Variables must be assigned names beginning with a lower case letter
Ruby --- VB
Nil ---- Nothing
--- Conversion methods ---
to_i = String to integer
to_f = String to float
to_s = Integer or float to string, Concantinates elements when used with string arrays.
--- Strings Manipulation ---
Literal Strings are denoted by single quote ( ' )
Backslash is an escape character: ' results in single quote. (\=)
Double quoted text is a more flexible form of string defintion. (Inserting and formating)
Ruby --- VB
------ & ------------------------ Concantination
------ Str(<string>, <count>) --- Repeat Char/String
------ ' ------------------------ Comments
--- Operators and Comparison Operators ---
Ruby --- VB
** ----- ^ ----- Exponent
% ------ Mod ----- Modulus
== ----- = ------ (Comparison) Equivalent
!= ----- <> ----- (Comparison) Not Equivalent
--- Bracket Characters ---
denote an array.
Curly Brackets { } denote a hash
Parenthisis ( ) used in a formula or logical statement work as they should but are optional for methods
--- Hashes / Dictionary ---
Define as you would an array but with curly brackets and a key.
myList = {}; myList{'Bob Mitchell'} = '54823-11'; myList{'Phil Brown'} = '23872-08'; #Etc...
--- Arrays ---
Arrays are denoted by square brackets rather than parenthisis
Arrays are zero based.
Arrays elements do not have to be all the same type.
Arrays as objects also have methods. (Push, Pop,Last, Length, Sort, Etc...)
--- Loops ---
Arrays have an interator method: While Loop myArray.Each do | <variable> | ... End
While <Statement True> puts <variable> puts <variable> end
--- User Methods ---
Last variable or Return <variable> Returns value
Ruby ----- VB
Def( ) --- Sub( ) or Function( )
--- Classes ---
Any class may be extended including Ruby's supplied classes.
The new method (Implied) is required for object instantiation.
An Initialize method may be declared inside a class.
The Initialize method can take user parameters. these parameters are required after the <Class>.new method.
Properties are defined by the use of the @prefix on variable names.
local variables are private to class
Private is a Class keyword in Ruby that defines all methods below it as internal to the class.
Ruby --- VB
Time --- Date