Tagged Questions
12
votes
2answers
71 views
Nokogiri crawler
The following code works but is a mess. But being totally new to Ruby I have had big problems trying to refactor it into something resembling clean OOP code. Could you help with this and explain what ...
1
vote
1answer
36 views
Cleaning up a class that contains the object it represents [closed]
I've recently started writing a tic-tac-toe game (following the Odin project) and am trying to write a class to hold the board game.
What I'm not sure about, is that the board class holds all the ...
7
votes
1answer
131 views
Less-repetitive code for document-analyzer
I've refactored my code such that every function has only one responsibility. Now I'd like like to work on making it DRY.
I'm noticing a lot of duplication in the ...
6
votes
2answers
52 views
Refactor an XML to JSON parser class
I used Nokogiri and a piece of ActiveSupport to parse an xml file from a given URL, format the data properly and return a JSON string. The script works as expected, so I'm only wondering if there are ...
1
vote
2answers
193 views
Tic-Tac-Toe implementation where computer should not lose
I have implemented Tic-Tac-Toe so that human can play with the computer, where the computer should never lose. I did a simple analysis before implementing, and I found out that there are certain ...
10
votes
3answers
189 views
Counting words / lines in Ruby - more compact / idiomatic way?
I solved this problem in Ruby:
Write an utility that takes 3 command-line parameters P1, P2 and P3.
P3 is OPTIONAL (see below) P1 is always a file path/name. P2 can take
the values:
...
2
votes
1answer
280 views
Searching over more models rails
I'm trying to implement search over two models. In this example Book and Article. Here are the attributes from both of these :
...
0
votes
1answer
96 views
How do I automatically call settings for each method? [closed]
I am using sendgrid gem to send emails and track by categories, class#method_name and arguments.
...
4
votes
2answers
328 views
Common Ruby Idioms
I'm a JavaScript developer. I'm pretty sure that will be immediately apparent in the below code if for no other reason than the level/depth of chaining that I'm comfortable with. However, I'm learning ...
3
votes
2answers
71 views
Review of OOP in Ruby class
Could you please review the following class products?
It should tell me whether the product is taxable or imported. Name should indicate if the product is imported or certain keywords should tell ...
2
votes
1answer
125 views
Needs code review for class implementation
could you please review the code for the implementation of the class (link: Ruby. Code review. Working alone on the code)
...
1
vote
2answers
153 views
General review of Robot class
I'm working alone on my code, trying to learn Ruby as I go.
Class Robot is supposed to be instantiated with the position on a map, and whether it is facing toward ...
3
votes
1answer
170 views
Delegating to a lazily loaded object in Ruby
I have an API that takes a class as a configuration parameter, but I don't want to load the class (I'm using Rails) at the time that I'm setting up the API. I figured I could get around this by ...