ruby Tutorials

1. Standard Library Packages in Ruby

By: Emiley J. : 2009-03-03

Description: This is a list of standard library packages in Ruby


2. Module Abbrev in Ruby

By: Emiley J. : 2009-03-03

Description: Given a set of strings, calculate the set of unambiguous abbreviations for those strings, and return a hash where the keys are all the possible abbreviations and the values are the full strings. Thus, given input of "car" and "cone", the keys pointing to "car" would be "ca" and "car", while those pointing to "cone" would be "co", "con", and "cone".


3. encoding and decoding in Ruby using Base64 Module

By: Emiley J. : 2009-03-03

Description: The Base64 module provides for the encoding (encode64) and decoding (decode64) of binary data using a Base64 representation.


4. Benchmark module in Ruby

By: Emiley J. : 2009-03-03

Description: The Benchmark module provides methods to measure and report the time used to execute Ruby code.


5. benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) {|report| ...} in Ruby

By: Jeya : 2009-03-03

Description: Invokes the block with a Benchmark::Report object, which may be used to collect and report on the results of individual benchmark tests. Reserves label_width leading spaces for labels on each line. Prints caption at the top of the report, and uses fmt to format each line. If the block returns an array of Benchmark::Tms objects, these will be used to format additional lines of output. If label parameters are given, these are used to label these extra lines.


6. bm(label_width = 0, *labels) {|report| ...} in Ruby

By: Jeya : 2009-03-03

Description: A simple interface to the benchmark method, bm is generates sequential reports with labels. The parameters have the same meaning as for benchmark.


7. bmbm(width = 0) {|job| ...} in Ruby

By: Jeya : 2009-03-03

Description: Sometimes benchmark results are skewed because code executed earlier encounters different garbage collection overheads than that run later. bmbm attempts to minimize this effect by running the tests twice, the first time as a rehearsal in order to get the runtime environment stable, the second time for real. GC.start is executed before the start of each of the real timings; the cost of this is not included in the timings. In reality, though, there’s only so much that bmbm can do, and the results are not guaranteed to be isolated from garbage collection and other effects.


8. CGI class in Ruby

By: Jeeva : 2009-03-03

Description: CGI is a large class, providing several categories of methods, many of which are mixed in from other modules. Some of the documentation is in this class, some in the modules CGI::QueryExtension and CGI::HtmlExtension. CGI::Cookie handles cookies.


9. URL encode a string in Ruby

By: Jeeva : 2009-03-03

Description: URL-encode a string.


10. escapeElement() in Ruby

By: Jeeva : 2009-03-03

Description: Takes an element or elements or array of elements. Each element is specified by the name of the element, without angle brackets. This matches both the start and the end tag of that element. The attribute list of the open tag will also be escaped (for instance, the double-quotes surrounding attribute values).