Ruby on rails can be downloaded from many sources over the internet like from http://api.rubyonrails.org/ where there are also instructions on how to quickly install and start programming. The first lessons would be the forever basic “Hello World” program which is very easy if you get set-up right. For a more automated installation you could [...]
Once you have successfully installed and tried that the install was a success through the Hello World program. You now begin building projects with the following syntax : “rails ProjectName”. You then start the WeBrick webserver with “cd ProjectName enter ./script/server”. The above procedures invoke the interpreter which may be required on some platforms as [...]
Blocks or simply chunks of code as in the last example may be existing variables which changes after that same variable passes thought the block, giving it a new value. Blocks may also be used to return a needed value to the method as in the last example, the resulting value of the last expression [...]
Also posted in Development | Tagged Blocks, Functions |
After it goes through the block, the file is closed taking with it the results of the block’s transactional process. This is something that should be done with all programming languages, to have the code have their own built-in file handling system which ensures that a file once opened is closed upon exit to avoid [...]
The sample code above shows the number of techniques that can be used to maximize the use of blocks for transactional control where the takeAndDosomething method is considered a class method and that it can be called independent or without influence of any single File Object. We used it to function in the same manner [...]
By Avatar | September 17, 2009
There are a variety iterators that are useful with Ruby such as we’ve already seen in previous samples of code, such as n.times. Others are n.upto and n.downto for going up or down a series of integers and the step, which is more like the traditional loop statement. Their usage would be somewhat like:
3.times {print”X [...]
Also posted in Development | Tagged Integers, Iterators |
We have looked into many of the data structures that are supported by ruby along with brief examples of their use and structures. Now we turn to the different data types the language supports which is vital in maximizing the potential of Ruby. Numbers are classified into integers and floating point numbers. The handling capabilities [...]
By Bart | August 18, 2008
Image source:www.flickr.com
Following the simple Rails programming gathering does more than just eradicate the need for configuration files. It also means that Rails can routinely handle myriad lower-level details without you having to tell it to do so. This means that you write fewer lines of code to implement your application. Keeping your code small means [...]
Containers is a term used to define arrays or tables for they are used to store variables which are then indexed to be able to retrieve data from them. Hashes on the other hand can be described as dictionaries or associative arrays which are also indexed along with all object references. Arrays are indexed using [...]
Below is an example of a document that consists of lines in the source but without the terminating string that is needed after the “<<” character. This terminator must start in the first column but with the minus “-” sign after the “<<” character, indention can be done on that specific terminator\ as shown below.
print [...]
Also posted in Development | Tagged literals, strings |