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.2.0 (2022-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

228397 questions
67
votes
5 answers

When to use `require`, `load` or `autoload` in Ruby?

I understand the subtle differences between require, load and autoload in Ruby, but my question is, how do you know which one to use? Other than being able to "wrap" a load in an anonymous module, require seems to be preferred. But then autoload…
Mark W
  • 2,522
  • 3
  • 18
  • 21
67
votes
6 answers

How to stub ApplicationController method in request spec

I am needing to stub the response of a current_user method in an Rspec/capybara request spec. The method is defined in ApplicationController and is using helper_method. The method should simply return a user id. Within the test, I'd like this method…
Matt Fordham
  • 3,147
  • 10
  • 34
  • 51
67
votes
3 answers

Ruby read CSV file as UTF-8 and/or convert ASCII-8Bit encoding to UTF-8

I'm using ruby 1.9.2 I'm trying to parse a CSV file that contains some French words (e.g. spécifié) and place the contents in a MySQL database. When I read the lines from the CSV file, file_contents = CSV.read("csvfile.csv", col_sep: "$") The…
user141146
  • 3,285
  • 7
  • 38
  • 54
67
votes
7 answers

convert string to specific datetime format?

String "2011-05-19 10:30:14" To Thu May 19 10:30:14 UTC 2011 How can I convert specific string to this Date format ?
krunal shah
  • 16,089
  • 25
  • 97
  • 143
67
votes
5 answers

Navigate to Ruby function definition in VS Code

I'm pretty new to Visual Studio Code, and I'm trying to edit some Ruby code. I installed Ruby support, and I enabled the language server, but Ctrl-clicking on a function name doesn't work, and neither does F12. Both of these features work fine for…
Don Kirkby
  • 53,582
  • 27
  • 205
  • 286
67
votes
5 answers

Regex, how to match multiple lines?

I'm trying to match the From line all the way to the end of the Subject line in the following: .... From: XXXXXX Date: Tue, 8 Mar 2011 10:52:42 -0800 To: XXXXXXX Subject: XXXXXXX .... So far I have: /From:.*Date:.*To:.*Subject/m But that doesn't…
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
67
votes
11 answers

How to obtain first day of next month in ruby?

I have a date of operation. I want create promissory notes which have got: day=1 month= the next month of operation_date year= automatic Example : operation_date = 15/11/2010 promissory_note1_date = 1/12/2010 promissory_note2_date =…
maxiperez
  • 1,470
  • 2
  • 20
  • 40
67
votes
11 answers

How do I describe an enumeration column in a Rails 3 migration?

How do I describe an enumeration column in a Rails 3 migration?
Zeck
  • 6,433
  • 21
  • 71
  • 111
67
votes
3 answers

How to know whether a model is new or not?

class Post < ActiveRecord::Base end post = Post.new How do I judge whether the 'post' is a new model which is not pulled from the database?
Croplio
  • 3,433
  • 6
  • 31
  • 37
67
votes
13 answers

Confused, are languages like python, ruby single threaded? unlike say java? (for web apps)

I was reading how Clojure is 'cool' because of its syntax + it runs on the JVM so it is multithreaded etc. etc. Are languages like ruby and python single threaded in nature then? (when running as a web app). What are the underlying differences…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
67
votes
7 answers

What is the "=~" operator in Ruby?

I saw this on a screencast and couldn't figure out what it was. Reference sheets just pile it in with other operators as a general pattern match operator.
CCSab
  • 1,455
  • 3
  • 16
  • 27
67
votes
9 answers

Why do this Ruby object have both to_s and inspect methods that appear to do the same thing?

Why do this Ruby object both a to_s and inspect methods that appear to do the same thing? The p method calls inspect and puts/print calls to_s for representing the object. If I run class Graph def initialize @nodeArray = Array.new …
prosseek
  • 182,215
  • 215
  • 566
  • 871
67
votes
4 answers

Rails: Should partials be aware of instance variables?

Ryan Bates' nifty_scaffolding, for example, does this edit.html.erb <%= render :partial => 'form' %> new.html.erb <%= render :partial => 'form' %> _form.html.erb <%= form_for @some_object_defined_in_action %> That hidden state makes me feel…
Alexandre
  • 5,035
  • 7
  • 29
  • 36
67
votes
3 answers

How to expect some (but not all) arguments with RSpec should_receive?

class Foo def bar(a, b) ... Foo.should_receive( :bar ) expects bar to be called with any arguments. Foo.should_receive( :bar ).with( :baz, :qux ) expects :baz and :qux to be passed in as the params. How to expect the first param to equal…
B Seven
  • 44,484
  • 66
  • 240
  • 385
67
votes
6 answers

How to install Ruby 2 on Ubuntu without RVM

I want to install ruby 2.0 using sudo apt-get install ruby2.0 But there isn't available package for ruby2.0 I want to install it using apt-get install the same like ruby 1.9.1 Any suggestions?
Mahmoud Khaled
  • 6,226
  • 6
  • 37
  • 42