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

Rails, How to render a view/partial in a model

In my model I have: after_create :push_create I push_create I need to render a view. I'm trying to do that like so: def push_event(event_type) X["XXXXX-#{Rails.env}"].trigger(event_type, { :content => render( :partial…
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
63
votes
4 answers

Create a ruby method that accepts a hash of parameters

I don't know how to create a ruby method that accepts a hash of parameters. I mean, in Rails I'd like to use a method like this: login_success :msg => "Success!", :gotourl => user_url What is the prototype of a method that accepts this kind of…
collimarco
  • 34,231
  • 36
  • 108
  • 142
63
votes
11 answers

How to group by count in array without using loop

arr = [1,2,1,3,5,2,4] How can I count the array by group value with sorting? I need the following output: x[1] = 2 x[2] = 2 x[3] = 1 x[4] = 1 x[5] = 1
Mr. Black
  • 11,692
  • 13
  • 60
  • 85
63
votes
6 answers

Super keyword in Ruby

What is the super for in this code? def initialize options = {}, &block @filter = options.delete(:filter) || 1 super end As far as I know it's like calling the function recursively, right?
mabounassif
  • 2,311
  • 6
  • 29
  • 46
63
votes
8 answers

How do I use RVM and create globally available gems?

I'm running Mac OSX 10.6.4 and have installed RVM. Its been great so far, I really love the way it lets me manage having multiple versions of rails and ruby on the same machine without headaches! However, I don't want to have to install certain…
GiH
  • 14,006
  • 13
  • 43
  • 56
63
votes
5 answers

What is the difference between "if" statements with "then" at the end?

What's the difference between these two Ruby if statements when we put a then at the end of the if statement? if(val == "hi") then something.meth("hello") else something.meth("right") end and if(val == "hi") something.meth("hello") else …
Mo.
  • 40,243
  • 37
  • 86
  • 131
63
votes
15 answers

Count the number of lines in a file without reading entire file into memory?

I'm processing huge data files (millions of lines each). Before I start processing I'd like to get a count of the number of lines in the file, so I can then indicate how far along the processing is. Because of the size of the files, it would not…
smnirven
  • 1,518
  • 1
  • 13
  • 15
63
votes
5 answers

What Ruby and Rails Developers Ought To Know?

What should someone know as an Entry Level, Mid-level, and Senior Developer working with Rails? Across the board: theoretical knowledge, development tools, gems and more. What issues usually are at the interview?
akrisanov
  • 3,212
  • 6
  • 33
  • 56
63
votes
5 answers

Set the display precision of a float in Ruby

Is it possible to set the display precision of a float in Ruby? Something like: z = 1/3 z.to_s #=> 0.33333333333333 z.to_s(3) #=> 0.333 z.to_s(5) #=> 0.33333 Or do I have to override the to_s method of Float?
salt.racer
  • 21,903
  • 14
  • 44
  • 51
63
votes
5 answers

What does the "$" character mean in Ruby?

Been playing with Ruby on Rails for awhile and decided to take a look through the actual source. Grabbed the repo from GitHub and started looking around. Came across some code that I am not sure what it does or what it references. I saw this code…
63
votes
11 answers

gem install fails with openssl failure

I tried to install cocoapods (http://cocoapods.org/) on my OSX Mountain Lion. moshe-mbp:~ moshem$ gem install cocoapods ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why: Unable to download data from https://rubygems.org/ -…
Moshe Marciano
  • 2,349
  • 4
  • 33
  • 44
63
votes
7 answers

Ruby XML to JSON Converter?

Is there a library to convert XML to JSON in Ruby?
Lance
  • 75,200
  • 93
  • 289
  • 503
63
votes
4 answers

What does to_proc method mean in Ruby?

I am learning rails and following this thread. I am stuck with the to_proc method. I consider symbols only as alternatives to strings (they are like strings but cheaper in terms of memory). If there is anything else I am missing for symbols, then…
swapnesh
  • 26,318
  • 22
  • 94
  • 126
63
votes
8 answers

How can I password-protect my /sidekiq route (i.e. require authentication for the Sidekiq::Web tool)?

I am using sidekiq in my rails application. By Default, Sidekiq can be accessed by anybody by appending "/sidekiq" after the url. I want to password protect / authenticate only the sidekiq part. How can i do that?
sagar junnarkar
  • 1,240
  • 2
  • 10
  • 18
63
votes
4 answers

How to save a base64 string as an image using ruby

I'm integrating my Ruby on Rails app with a usps shipping system. Once you make a postage request, you pay for that postage and it's nonrefundable. Postage requests will return you an xml response including a base64 string, which is the shipping…
Ricky
  • 753
  • 1
  • 6
  • 7