My name is Edward Tanguay. I am a web developer in Berlin, Germany. I learn everything I can and record it on this site. Other things you might be looking for: My Ubuntu Tutorial My Datapod Project My Blog Feed:  | | Most Recent Items
|
RUBY CODE EXAMPLE
- added on May 27, 2007
Here is how to do functions in ruby, note the parameter syntax that is used often in Rails.
| post comment or questionpost comment or question |
|
|
|
RUBY CODE EXAMPLE
- added on May 24, 2007
Ruby has a unique and terse iterator, what is between the pipes is the variable, that's it.
Karen: I am looking for a way to have ruby execute a command for example rake. Is it possible to do so?
Thanks much in advance!  | Sean Kellogg: In Ruby it is possible to execute shell commands by using the command expansion form:
%{command}
where command is the text you would ordinarily write on the command line. For example,
tests.each do |test|
puts "running #{test} starting ..."
%x{rake #{test}}
puts "test #{test} completed"
end
Also possible is to enclose the command in backticks like this:
`command` |
 | Sean Kellogg: If the above was unclear (due to suppressed newline characters) try the following iterator: tests.each { |test| %x{rake #{test}} } | post comment or questionpost comment or question |
|
|
|
RUBY CODE EXAMPLE
- added on May 24, 2007
When you use Rails, symbols are use in hashs (since they take up less storage).
| post comment or questionpost comment or question |
|
|
|
RUBY CODE EXAMPLE
- added on May 24, 2007
Use the .. or the ... (to exclude the last number, i.e. 20). The "to_a" means "to array".
post comment or questionpost comment or question |
|
|
RUBY CODE EXAMPLE
- added on April 16, 2007
Shows you how attr_reader simplifies properties.
post comment or questionpost comment or question |
|
|
RUBY CODE EXAMPLE
- added on September 17, 2006
This basic code shows you how easy it is to use getters and setters in ruby.
| post comment or questionpost comment or question |
|
|
|
RUBY CODE EXAMPLE
- added on September 17, 2006
This code shows you how you can use the super command to call base methods.
| post comment or questionpost comment or question |
|
|
|
RUBY CODE EXAMPLE
- added on September 17, 2006
Shows how to use the keyword super to call a base class method.
post comment or questionpost comment or question |
|
|
RUBY CODE EXAMPLE
- added on September 17, 2006
Notice here how you can extend a class (even a system class) at any time just by making a new definition of the class and adding a method, like partial classes in C#.
| post comment or questionpost comment or question |
|
|
|
RUBY CODE EXAMPLE
- added on September 14, 2006
This shows how to make a class in ruby, notice how you have have partial classes (like in C# 2.0) defined anywhere and they fit together as one class.
| post comment or questionpost comment or question |
|
|
|
RUBY CODE EXAMPLE
- added on September 14, 2006
This code will teach you some basics of Ruby, note the wierd way of iterating with method calls.
post comment or questionpost comment or question |
|
|
RUBY CODE EXAMPLE
- added on September 8, 2006
This shows you how to use "require" to emulate PHP's include() command so that you can include libraries in your ruby pages. It seems that the library files need to have the extension ".rb".
post comment or questionpost comment or question |
|
|
RUBY CODE EXAMPLE
- added on September 8, 2006
This is the easiest way to make functions out of any language I've tried. Make sure the function comes BEFORE the code that uses it.
post comment or questionpost comment or question |
|
|
RUBY CODE EXAMPLE
- added on September 8, 2006
This is the simplest code I got to work on my provider. Note that you need the .htaccess file in the same directory and you need to set the rights on this file to 755.
post comment or questionpost comment or question |
|
|