Questions tagged [ruby]

Ruby is a multi-platform open-source, dynamic object-oriented interpreted language. The [ruby] tag is for questions related to the Ruby language, including its syntax and its libraries. Ruby on Rails questions should be tagged with [ruby-on-rails].

The tag is for questions related to the Ruby language, including its syntax and its libraries. Questions specifically about the Ruby on Rails framework should be tagged with in addition to . Do not use this to tag ruby used in the Japanese language.

Ruby is an open-source dynamic object-oriented interpreted language that combines concepts from Perl, Smalltalk, and Lisp. It supports multiple programming paradigms including functional, object-oriented, and imperative. It also has a dynamic type system and automatic memory management; it is, therefore, similar in varying respects to Smalltalk, Python, Perl, Lisp, Dylan, and CLU. Ruby's primary purpose is to "help every programmer in the world to be productive, and to enjoy programming, and to be happy." Ruby focuses on simplicity and productivity.

Ruby was initially conceived on February 24, 1993, by Yukihiro Matsumoto ('Matz') and version 1.0 was released in 1996. Ruby's mindshare spiked around 2005 due to Ruby on Rails, an MVC (Model, View, Controller) framework for building web applications and usage continues to grow as of 2016 with Ruby continuing to find acceptance in the commercial marketplace. The current stable version is 3.0.0 (2020-12-25).

Documentation, Announcements, Issue Tracker

Unofficial Reference

Implementations, Installers

  • Ruby version managers. chruby, rbenv, rvm, pik (Windows)
  • Ruby, the official implementation also known as Matz' Ruby Implementation (MRI), YARV-Ruby. Official Site, GitHub
  • JRuby, an implementation of Ruby on top of Java with access to the JVM
  • Rubinius, an implementation of Ruby supporting native OS threads and a core library written almost entirely in Ruby
  • Ruby Enterprise Edition (not maintained anymore), a branch of MRI Ruby made for efficiency
  • MacRuby, an implementation of Ruby on Apples Objective-C and Cocoa frameworks
  • MagLev an implementation on top of VMWare's GemStone virtual machine
  • IronRuby is an implementation of Ruby on top of Microsoft's .NET CLR/DLR platform
  • Cardinal is an implementation of Ruby for the Parrot Virtual Machine
  • Topaz is an implementation of Ruby written in Python, on top of RPython
  • RubyMotion is an implementation of Ruby to develop native iOS and OS X applications

Gems (Library)

  • Ruby Gems - The Standard Library
  • Ruby Toolbox - Ruby Gems categorization, ranking, and statistics
  • Awesome Ruby - A categorized collection of awesome Ruby libraries, tools, frameworks, and software. The essential Ruby to build modern Apps and Web Apps
  • Bundler - Manage your application's gem dependencies
  • DevKit - A windows toolkit that makes it easy to build and use native C/C++ extensions

Tools

  • repl.it - Online REPL
  • RSpec - A testing tool for Ruby
  • Minitest - A testing tool for Ruby
  • Rubular - A Ruby regular expression tool
  • Pry - REPL and debugger for Ruby
  • Rubocop - A Ruby linter and code formatter

Online Courses

Books

Related Tags


Icon:

ruby icon

219518 questions
2168
votes
26 answers

How to write a switch statement in Ruby

How do I write a switch statement in Ruby?
readonly
  • 306,152
  • 101
  • 198
  • 201
1389
votes
26 answers

How to check if a value exists in an array in Ruby

I have a value 'Dog' and an array ['Cat', 'Dog', 'Bird']. How do I check if it exists in the array without looping through it? Is there a simple way of checking if the value exists, nothing more?
user211662
  • 16,517
  • 8
  • 23
  • 19
1165
votes
15 answers

How to understand nil vs. empty vs. blank in Ruby

I find myself repeatedly looking for a clear definition of the differences of nil?, blank?, and empty? in Ruby on Rails. Here's the closest I've come: blank? objects are false, empty, or a whitespace string. For example, "", " ", nil, [], and {}…
Arrel
  • 13,100
  • 7
  • 22
  • 22
1162
votes
20 answers

How to call shell commands from Ruby

How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?
CodingWithoutComments
  • 33,560
  • 21
  • 70
  • 85
1145
votes
11 answers

How to convert a string to lower or upper case in Ruby

How do I take a string and convert it to lower or upper case in Ruby?
Heat Miser
  • 18,606
  • 7
  • 32
  • 37
1139
votes
19 answers

How to pass command line arguments to a rake task

I have a rake task that needs to insert a value into multiple databases. I'd like to pass this value into the rake task from the command line, or from another rake task. How can I do this?
Tilendor
  • 45,619
  • 15
  • 48
  • 58
1086
votes
33 answers

How do I get the current absolute URL in Ruby on Rails?

How can I get the current absolute URL in my Ruby on Rails view? The request.request_uri only returns the relative URL.
Jakub Arnold
  • 79,807
  • 86
  • 218
  • 314
1069
votes
20 answers

What is attr_accessor in Ruby?

I am having a hard time understanding attr_accessor in Ruby. Can someone explain this to me?
dennismonsewicz
  • 23,382
  • 26
  • 107
  • 175
1063
votes
12 answers

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

I don't use the RI or RDoc output from the gems I install in my machine or in the servers I handle (I use other means of documentation). Every gem I install installs RI and RDoc documentation by default, because I forget to set --no-ri --no-rdoc. Is…
Ricardo Acras
  • 34,766
  • 15
  • 66
  • 109
1007
votes
10 answers

Understanding the Rails Authenticity Token

I am running into some issues regarding the Authenticity Token in Rails, as I have many times now. But I really don't want to just solve this problem and go on. I would really like to understand the Authenticity token. Well, my question is, do you…
Ricardo Acras
  • 34,766
  • 15
  • 66
  • 109
950
votes
7 answers

Ruby: How to install a specific version of a ruby gem?

Using the command-line gem tool, how can I install a specific version of a gem?
mjs
  • 57,072
  • 26
  • 82
  • 114
926
votes
6 answers

Why is it bad style to `rescue Exception => e` in Ruby?

Ryan Davis’s Ruby QuickRef says (without explanation): Don’t rescue Exception. EVER. or I will stab you. Why not? What’s the right thing to do?
John
  • 27,017
  • 10
  • 70
  • 76
911
votes
6 answers

class << self idiom in Ruby

What does class << self do in Ruby?
randombits
  • 41,533
  • 69
  • 218
  • 394
892
votes
8 answers

What does %w(array) mean?

I'm looking at the documentation for FileUtils. I'm confused by the following line: FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6' What does the %w mean? Can you point me to the documentation?
Dane O'Connor
  • 67,996
  • 36
  • 114
  • 164
798
votes
17 answers

How to get a random number in Ruby

How do I generate a random number between 0 and n?
Mark A. Nicolosi
  • 72,599
  • 10
  • 41
  • 46
1
2 3
99 100