Calling an object method in Ruby behind the scenes is actually a message to another object or Message Passing. These can more easily be understood by an example, and for that reason lets look at a basic multiplication script. 3 x 4 As you are aware everything in Ruby is an object, including an integer.…
Ruby
THe inner workings of Ruby Message Passing : Lesson 10 of My Self-Inflicted Crash Course into Ruby
Iterating over collections in Ruby: Lesson 9 of My Self-Inflicted Crash Course into Ruby
Ruby provides a multitude of methods and structures for iterating or looping through arrays and collections. The most commonly used methods are the basic for and each loops. However there exists other convenience (or code bloat) methods on both arrays and integers to also perform iteration. The basic FOR loop The for loop in Ruby…
The Ruby Case Statement a.k.a the Switch Statement: Lesson 8 of My Self-Inflicted Crash Course into Ruby
Most developers are aware of the Switch statement that compares a variable to specific cases and performs logic based on if it matches the case criteria. In Ruby they decided to implement this as simply a Case statement with when clauses specifying logic to be performed if the when clause is true. case year when…
Conditional Statements the many ways to test a condition: Lesson 7 of My Self-Inflicted Crash Course into Ruby
One of the most integral parts to programming is the basic IF statement or the conditional Statement. Ruby like most if not all languages uses the if keyword to define an IF statement. However it defers from other languages as you can use the if keyword as a statement or a modifier. In addition Ruby…
Method Access Control, Coming to terms with Ruby’s definition of Public, Protected, and Private: Lesson 6 of My Self-Inflicted Crash Course into Ruby
When learning Ruby with a background in Java/C# .NET and similar high level object oriented programming languages method visibility can be a major stumbling block. To start things off all Ruby methods are by default public or accessible by any object. To limit access you have the option of modifying a methods visibility to either…
Class instance variables Access Modifiers: Lesson 5 of My Self-Inflicted Crash Course into Ruby
Ruby has many built in shortcuts for allowing access to instance variables. In most languages (Java, PHP ) you typically define your Class properties/variables then would go about defining getter / setter methods for each variable. In Ruby they have defined attribute modifiers to easily define the getter setter methods without having to write them…
Modifying existing Classes – Lesson 4 of My Self-Inflicted crash course into Ruby
Ruby is definitely a loose language. All classes in the language even core classes like the base Object are open and can be modified at any time. Also Ruby in addition to allowing you to do object inheritance allows you to include and extend modules within your Classes. Open Classes What open classes means is…
Ruby Naming Conventions – Lesson 3 of My Self-Inflicted crash course into Ruby
Taking a break from diving into further details of Classes and Objects, I have detoured into taking a closer look at some of the naming conventions that are used in the Ruby programming language. In particular we are going to look at Constants and local, global, instance, and class variables. Constants In Ruby you define…
Processing – an interesting tool for visualizing data and artistic creation through code.
Processing is an open source programming language that has been around since 2001, and has steadily become a comprehensive alternative to proprietary software for the creation of images, motion graphics and teaching aid to students. This Java based language and environment allows you to quickly and easily create mesmerizing graphics in 2D and 3D that…
Understanding Ruby Classes and Methods Part 1 – Lesson 2 of My Self-Inflicted crash course into Ruby
Previously in Lesson 1 of this Ruby crash course I spoke mainly about getting Ruby setup and some basic differences in the syntax. In this lesson we are going to focus and creating classes and methods in Ruby. Defining a Method in Ruby Ruby like PHP is a scripting language. What this means is that…