Find an Online Tutor Now

21 Answered Questions for the topic Ruby

Describe the four pillars of object oriented programming

Encapsulation, Inheritance, Abstraction, Polymorphism

Creating An Air Pollution Index Reader in Ruby (Straight Forward Question)

I got stuck halfway with this question, im unable to post the image because im required to get 10 reputation points here lol. So i literally recreated the whole question here. There were no files... more
Ruby Php Perl


Is dynamic language always interpreted?

Looking at most (if not all) dynamic languages [i.e Python, PHP, Perl and Ruby], they are all interpreted. Correct me if I'm wrong. Is there any example of dynamic language that goes through... more


Safe integer parsing in Ruby?

I have a string, say `'123'`, and I want to convert it to `123`.I know you can simply do `some_string.to_i`, but that converts `'lolipops'` to `0`, which is not the effect I have in mind. I want it... more


Map and Remove nil values in Ruby?

I have a map which either changes a value or sets it to nil. I then want to remove the nil entries from the list. The list doesn't need to be kept.This is what I currently have:<!-- language:... more


How to document Ruby code?

Are there certain code conventions when documenting Ruby code? For example I have the following code snippet: require 'open3' module ProcessUtils # Runs a subprocess and applies... more
Ruby Regex


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.


How many types of variables are used in Ruby and what are they?


Test whether a Ruby class is a subclass of another class?

I would like to test whether a class inherits from another class, but there doesn't seem to exist a method for that. class A end class B < A end B.is_a? A => false ... more
Ruby Terminal


How to execute a Ruby script in Terminal?

I've set everything up that I need on my Mac (Ruby, Rails, Homebrew, Git, etc), and I've even written a small program. Now, how do I execute it in Terminal? I wrote the program in Redcar and saved... more


What is the difference between the Object methods clone and dup?


Undo scaffolding in Rails?

Is there any way to 'undo' the effects of a scaffold command in Rails?
Ruby String


How to check whether a string contains a substring in Ruby?

I have a string variable with content as follows: varMessage = "hi/thsid/sdfhsjdf/dfjsd/sdjfsdn\ " "/my/name/is/\ " ... more


How do I create an average from a Ruby array?

How would get find an average from an array?If I have the array: [0,4,8,2,5,0,2,6]Averaging would give me 3.375.Thanks!


In Ruby, how do I skip a loop in a .each loop, similar to 'continue'?

In Ruby, how do I skip a loop in a `.each` loop, similar to `continue` in other languages?
Ruby String Arrays


How to split a delimited string in Ruby and convert it to an array?

I have a string `"1,2,3,4"` and I'd like to convert it into an array: [1,2,3,4]How?


What is attr_accessor in Ruby?

I am having a hard time understanding `attr_accessor` in Ruby. Can someone explain this to me?
Ruby Arrays Loops


What is the "right" way to iterate through an array in Ruby?

PHP, for all its warts, is pretty good on this count. There's no difference between an array and a hash (maybe I'm naive, but this seems obviously right to me), and to iterate through either you... more


Convert string to symbol-able in Ruby?

Symbols are usually represented as such :book_author_titlebut if I have a string: "Book Author Title"is there a built in way in rails/Ruby to convert it into a symbol where I can use the `:` ... more


Using Ruby Programming

Design a class Rational for fractions (n, d), d > 0 where both are relatively prime integers with gcd(n, d) = 1. Again provide constructors, accessors, mutators, to string, to double, etc. as... more

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.