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
10 answers

Ruby check if nil before calling method

I have a string in Ruby on which I'm calling the strip method to remove the leading and trailing whitespace. e.g. s = "12345 " s.strip However if the string is empty nil I get the following error. NoMethodError: undefined method `strip' for…
user1513388
  • 7,165
  • 14
  • 69
  • 111
66
votes
11 answers

Natural Language Processing in Ruby

I'm looking to do some sentence analysis (mostly for twitter apps) and infer some general characteristics. Are there any good natural language processing libraries for this sort of thing in Ruby? Similar to Is there a good natural language…
Joey Robert
  • 7,336
  • 7
  • 34
  • 31
66
votes
4 answers

Convert string to decimal number in ruby

I need to work with decimals. In my program, the user need to put a number with decimals to convert that number. The problem is: If I try to convert the argument into a number I get a integer without decimals. # ARGV[0] is: 44.33 size =…
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
66
votes
6 answers

redirect_to using POST in rails

Is it possible to redirect using a POST method ? Or should redirects always be made using GET ? The use for this is in the final steps of an order process for an e-commerce site, to send the data to the payment processor, without introducing an…
andi
  • 14,322
  • 9
  • 47
  • 46
66
votes
5 answers

How to understand the difference between class_eval() and instance_eval()?

Foo = Class.new Foo.class_eval do def class_bar "class_bar" end end Foo.instance_eval do def instance_bar "instance_bar" end end Foo.class_bar #=> undefined method ‘class_bar’ for Foo:Class Foo.new.class_bar #=>…
pez_dispenser
  • 4,394
  • 7
  • 37
  • 47
66
votes
4 answers

Add gem to gemfile with bundler from command line

When using node package manager you can specify npm install --save mynodemodule which automatically pops the module in package.json I was wondering if there is a command for bundler that allows you to add the gem and version to the gemfile from the…
sren
  • 3,513
  • 4
  • 25
  • 28
66
votes
7 answers

Convert an array of integers into an array of strings in Ruby?

I have an array: int_array = [11,12] I need to convert it into str_array = ['11','12'] I'm new to this technology
swathi
66
votes
1 answer

How do you say not equal to in Ruby?

This is a much simpler example of what I'm trying to do in my program but is a similar idea. In an, if statement how do I say not equal to? Is != correct? def test vara = 1 varb = 2 if vara == 1 && varb != 3 puts "correct" else puts…
Ger Crowley
  • 901
  • 2
  • 10
  • 10
66
votes
8 answers

Why are methods in Ruby documentation preceded by a hash sign?

When I see any Ruby method printed in text, it usually appears as: Class#method or #method Now, I would use: Class.method Why are all Ruby methods preceded by a pound sign? Is there any reason for it?
Ed S.
  • 122,712
  • 22
  • 185
  • 265
66
votes
7 answers

Ruby Hash Whitelist Filter

I am trying to figure out how I can filter out key and value pairs from one filter into another For example I want to take this hash x = { "one" => "one", "two" => "two", "three" => "three"} y = x.some_function y == { "one" => "one", "two" =>…
stellard
  • 5,162
  • 9
  • 40
  • 62
66
votes
1 answer

Ruby on Rails Switch

Can someone provide an example on how to use switch case in Ruby for variable?
glarkou
  • 7,023
  • 12
  • 68
  • 118
66
votes
6 answers

Insecure world writable dir /Users/username in PATH, mode 040777 when running Ruby commands

When I run Ruby commands like gem -v I get this error: /Users/kristoffer/.rvm/rubies/ruby-1.9.2-p180/bin/gem:4: warning: Insecure world writable dir /Users/kristoffer in PATH, mode 040777 1.6.2 First of all I don't understand what this means.…
kristofferR
  • 763
  • 1
  • 6
  • 5
66
votes
3 answers

How to fix Rails's warning messages with Ruby 2.7.0

Did anyone resolve this issue with Ruby 2.7.0? I used rbenv and installed Ruby v2.7.0 and then created a Rails project using Rails v6.0.2.1. Currently, by running one of rails s rails s -u puma rails s -u webrick the server is up and the site is…
Nezir
  • 6,727
  • 12
  • 54
  • 78
66
votes
4 answers

Rails Migration with adding and removing reference

After creating a migration file with rails generate migration AddClientToUser I can edit my migration file like so: class AddClientToUser < ActiveRecord::Migration def self.up change_table :users do |t| t.references :client end …
Matt Connolly
  • 9,757
  • 2
  • 65
  • 61
66
votes
3 answers

YAML How many spaces per indent?

Is there any difference if i use one space, two or four spaces per indent level in YAML? Are there any specific rules for space numbers per Structure type?? For example 4 spaces for nesting maps , 1 space per list item etc?? I am writing a yaml…
Anestis Kivranoglou
  • 7,728
  • 5
  • 44
  • 47