33 Answered Questions for the topic Ruby
05/29/20
Describe the four pillars of object oriented programming
Encapsulation, Inheritance, Abstraction, Polymorphism
10/22/19
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
07/29/19
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
06/13/19
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
Ruby
06/12/19
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
Ruby
06/11/19
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 Exec
06/11/19
Ruby, Difference between exec, system and %x() or Backticks?
What is the difference between the following Ruby methods?`exec`, `system` and `%x()` or *Backticks*I know they are used to execute terminal commands programmatically via Ruby, but I'd like to know...
more
Ruby File Io
06/07/19
How to write to file in Ruby?
I need to read the data out of database and then save it in a text file.How can I do that in Ruby? Is there any file management system in Ruby?
Ruby Regex
06/07/19
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.
06/07/19
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
06/07/19
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
06/06/19
Undo scaffolding in Rails?
Is there any way to 'undo' the effects of a scaffold command in Rails?
Ruby String
05/30/19
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/balaji.so\ " ...
more
05/30/19
What does the "map" method do in Ruby?
I'm new to programming. Can someone explain what `.map` would do in: params = (0...param_count).map
Ruby Ruby On Rails
05/30/19
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!
Ruby
05/29/19
Is There a Better Way of Checking Nil or Length == 0 of a String in Ruby?
Is there a better way than the following to check to see if a string is nil OR has a length of 0 in Ruby?<!-- language: lang-Ruby --> if !my_string || my_string.length == 0 return...
more
05/22/19
Why are exclamation marks used in Ruby methods?
In Ruby some methods have a question mark (`?`) that ask a question like `include?` that ask if the object in question is included, this then returns a true/false.But why do some methods have...
more
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 Operators
05/22/19
Difference between "and" and && in Ruby?
What is the difference between the `&&` and `and` operators in Ruby?
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?
Ruby String
04/28/19
Ruby capitalize every word first letter?
I need to make the first character of every word uppercase, and make the rest lowercase... manufacturer.MFA_BRAND.first.upcaseis only setting the first letter uppercase, but I need this: ALFA...
more
04/12/19
How to make a HTTP request using Ruby on Rails?
I would like to take information from another website. Therefore (maybe) I should make a request to that website (in my case a HTTP GET request) and receive the response. How can I make this in...
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.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.