Cool things you can do with Ruby
- Rails - model-view-controller made easy, or Zope-done-right
- RDoc - Ruby's documentation generator; check out the autogenerated diagrams in all of the classes
- Test::Unit - Unit testing, of course.
- open-uri - Overrides the built-in Kernel.open method to open URIs as standard IO objects
Random cool things about the language itself
- Syntax looks like python, but indentation doesn't matter. Newlines instead of (optional) semicolons.
- rdoc (like javadoc) reads regular comments (can format using wiki-like markup) can output to YAML, and ri (like perldoc) reads docs in YAML
- Hash objects can have complex default values:
h = Hash.new { |hash, key| hash[key] = "Go Fish: #{key}" }
h["c"] #=> "Go Fish: c"
- Strings can have random expressions interpolated, not just variables:
puts "The answer to 3 + 4 is #{3 + 4}." #=> The answer to 3 + 4 is 7.
- File.open can take a filename and a block as parameters; it opens the given file, executes the block, then closes the file in one shot.
- irb, the Interactive Ruby shell
- The ability to see nearly any global, class, instance, or local variable/method (Kernel.global_variables, Object.methods, ObjectSpace::each_object, etc.)
- Python-like intelligent program usage parsing/generation with OptionParser
Examples
- Python:
str(int(min([5.6, 3.4, 6.5]))]
- Ruby:
[5.6, 3.4, 6.5].min.to_i.to_s
Cool Ruby apps