Ruby is an open-source dynamic object-oriented interpreted language created by Yukihiro Matsumoto (Matz) in 1993.

learn more… | top users | synonyms | ruby jobs

512
votes
5answers
96k views

How can I write a switch statement in Ruby?

How do I write a switch statement in Ruby?
349
votes
7answers
56k views

How to make --no-ri --no-rdoc the default for gem install?

I don't use RI or RDoc from the gems I install in my machine or in the servers I handle (I use other means of documentation), but every gem I install comes with RI and RDoc by default and I forget to ...
286
votes
7answers
65k views

How do I pass command line arguments to a rake task?

I've got a rake task that I am making that needs to insert a value into multiple databases. I'd like to be able to pass this value into the rake task from the command line, or from another rake ...
251
votes
9answers
153k views

How to get a random number in Ruby?

In Ruby, how do you generate a random number between 0 and n? In .NET you can create a Random object, does something like this exist for Ruby?
239
votes
12answers
51k views

Why are scripting languages (e.g. Perl, Python, Ruby) not suitable as shell languages? [closed]

What are the differences between shell languages like bash, zsh, fish and the scripting languages above that makes them more suitable for the shell? When using the command line the shell languages ...
230
votes
6answers
51k views

How to remove rvm (ruby version manager) from my system?

How can I remove rvm (ruby version manager) from my system?
224
votes
35answers
83k views

How best to generate a random string in Ruby

I'm currently using the following to generate an 8 character pseudo random upper case string [A-Z] value = ""; 8.times{value << (65 + rand(25)).chr} but it looks junky, and since it isn't a ...
217
votes
15answers
57k views

Can't install Ruby under Lion with RVM – GCC issues

Most questions regarding this problem are due to missing Xcode; I have Xcode 4.2 installed. Install attempt: rvm install 1.9.3 Installing Ruby from source to: /Users/jamie/.rvm/rubies/ruby-1.9.3-p0, ...
205
votes
8answers
42k views

What does “WARN Could not determine content-length of response body.” mean and how to I get rid of it?

Since upgrading to Rails 3.1 I'm seeing this warning message in my development log: WARN Could not determine content-length of response body. Set content-length of the response or set ...
199
votes
11answers
91k views

Calling Bash Commands From Ruby

How do I call console/bash commands from inside of a Ruby Program? Also, how do I get output from these commands back into my program?
192
votes
1answer
48k views

Match All Occurrences of a Regex

Is there a quick way to find every match of a regular expression in Ruby? I've looked through the Regex object in the Ruby STL and searched on Google to no avail.
187
votes
9answers
80k views

How does one convert a string to lowercase in Ruby?

I know this is simple, but how do you take a string and convert it to lower case, or upper case, in Ruby?
182
votes
8answers
72k views

Checking if a variable is defined in Ruby

How do you check whether a variable is defined in Ruby? Is there an "isset"-type method available?
182
votes
1answer
19k views

class << self idiom in Ruby

I suppose my question is exactly what the subject depicts, what does: class << self do in Ruby?
180
votes
7answers
66k views

check if value exists in array in Ruby

If I have a value 'Dog' and an array ['Cat', 'Dog', 'Bird'], how do I check this w/o looping through. Is there a simple way of checking if the value exists, nothing more?

1 2 3 4 5 5009
15 30 50 per page