Author Archives: Avatar

Blocks for Transactions Discussed (Part 1)

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 [...]

Posted in Development, Programming Basics, Programming Language | Tagged , | Comments closed

Integers and Iterators

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 [...]

Posted in Development, Programming Basics | Tagged , | Comments closed

Ruby Data Types

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 [...]

Posted in Development, Programming Basics | Tagged , , | Comments closed

Containers and Hashes

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 [...]

Posted in Development, Programming Basics | Tagged , | Comments closed

Ruby On Rails a look Back

Ruby was initially released on 1995 by a Japanese Programmer who got tired of the old-style complicated languages that were currently in use during the time. To this day, ROR continues to evolve as a dynamic language for it is open sourced and available to the public for personal use. Commercial use of the program [...]

Posted in Imp @ja | Comments closed

Strings (Part 4)

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 [...]

Posted in Development, Programming Basics | Tagged , | Comments closed

Strings (Part 3)

There are more ways of constructing string literals such as %q, %Q and “here documents.” The first two are used to starte single or double-quoted strings such as;
%q/general single-quoted string/ >> general single-quoted string
%Q!general single-quoted string! >> general double-quoted string
%Q{Seconds/day: #{24*60*60}} >> Seconds/day: 86400
The character following the “q” or “Q” is the delimiter that if it is an [...]

Posted in Development, Programming Basics | Tagged , | Comments closed

Strings (Part 2)

The types of substitution can be easily seen such as; strings inside a single quote have two consecutive backslashes interpreted as one, a backslash followed by a single quote is interpreted as a single quote and so on and so forth as shown below.
‘escape using “\\”‘ >> escape using “\”
‘That\’s right’ >> That’s right
Stings that are double-quoted have the [...]

Posted in Development, Programming Basics | Tagged , | Comments closed

Strings (Part 1)

Strings are objects of class String, which are normally simple 8-bit bytes that normally hold printable characters but that is not a requirement as you would see for they could also be used to hold binary data. Created using string literals (which are sequences of characters between delimiters that themselves do some conversion of the [...]

Posted in Development, Programming Basics | Tagged , , | Comments closed

Perl Differences in string handling

A note to Perl users, strings that contain numbers will not be automatically converted to numbers when used in an expression such as when trying to read numbers from a file like the one below does.
DATA.each do |line|
vals = line.split # split line, storing tokens in val
[...]

Posted in Development, Programming Basics | Tagged , | Comments closed