Ruby is a multi-platform, open-source, dynamic, object-oriented, interpreted language created by Yukihiro Matsumoto (Matz) in 1993.
1
vote
0answers
9 views
Rails API for communication between two Rails app where the former app posts data to the latter and the latter return a response
The Controller code for the first app to post data to another app
...
1
vote
0answers
9 views
Creating a list of things by looking up multiple sources
I am trying to write a rspec webmock test for a rails PORO model. What this model does is, query bugzilla with a set of filters for a list of bugs and iterate over it such that:
The bug ids are used ...
1
vote
1answer
25 views
Gem to interact with a third party API
I am writing a gem for users to interact with a third party api. I want users to have easy and natural access to objects and properties delivered by the JSON payload.
The collection of entities ...
0
votes
0answers
16 views
Another Tic Tac Toe In Ruby
I am messing with Ruby a little bit and would like to get some feedback about the Spaghettii below :)
...
4
votes
1answer
43 views
Stack class in Ruby to calculate maximum number, get the average, pop, push
Is the class optimized enough to accept 1 million items in the stack?
...
4
votes
0answers
34 views
Brainf**k interpreter in Ruby
I wrote this interpreter for a code challenge. Can this be written any cleaner/smaller? Could I reduce the amount of nested conditional/loops?
...
1
vote
0answers
25 views
Class/model hierarchy for a school-management application
Please find how I would model a system that had teachers, students, classes and parents. Instead of creating a model for each user type, I created only two models, ...
4
votes
3answers
55 views
Getting the Twitter account from various input formats
I have an input for users to enter a Twitter account in any different way and I want to extract the user account.
For example:
...
2
votes
1answer
23 views
Regex detection for Puppet configuration
I've got a PR to add a feature to a Ruby application (Puppet) to allow Regex detection.
Right now, the method only does comparison on exact string matching:
...
4
votes
1answer
29 views
Deserializer in ruby
Given a serialized hash of any depth in string format, convert it into a hash object.
I want to know if my approach is correct, I am capturing states and storing the results in a stack and generating ...
3
votes
1answer
42 views
Machi Koro card/dice game
I have taken advice on board and had a go at a new project, to write a program that lets you play the card/dice game, Machi Koro. The complexity of the game isn't too great, which makes it a good ...
3
votes
1answer
45 views
Mastermind game - Evaluating the guess in Ruby
I am a novice coder and I am very new to algorithms. Something about my code leads me to believe that it is unnecessarily verbose and/or inefficient. I am building a command line Mastermind game, and ...
-2
votes
2answers
60 views
Advice on Optimizing Ruby Code Structure
I have the current code structure which works but i feel there should be a better way of optimizing the code structure or writing it much more cleaner.
Can anyone suggest a better way to represent ...
-1
votes
1answer
31 views
Validating only attributes that are present in a form [closed]
I want to skip validations based on attributes. If certain attributes are not in form so I do not want to validate them.
Currently, if I post them from one form which has 1 field, it still validates ...
1
vote
1answer
42 views
Tic Tac Toe in Ruby
I'm a novice programmer going through the Odin Project. I just finished up building a command line Tic Tac Toe game and I would appreciate some feedback on object-oriented design, methods, verbosity, ...
5
votes
1answer
50 views
Web Development DSL
I'm working on a DSL for web development, similar to sinatra. The git repository is here. I've been attempting to improve this code and write it for 4 months, and as a hobby programmer, I would like ...
-1
votes
1answer
50 views
How to run this code faster
This sample code is correct and no error however this only good if you only have few hundreds or thousand datas but if you have million queries this takes time how we can improve this algorithm
...
2
votes
2answers
82 views
Build a pizza and choose your toppings
I've created a scenario below, in which a user can build a pizza and choose their toppings, then order their pizza:
...
3
votes
1answer
57 views
Helper that swaps out some text for certain icons
I have a Rails helper that swaps out some text for certain icons.
Example:
Helper Sample
...
1
vote
0answers
50 views
Ruby - Asteroids Remake
After some feedback on my last Ruby Code I decided to start another one with two big concerns in mind:
Trying to adequate my coding to the OOP paradigm
Trying to follow the Ruby Style-Guideliness
I ...
1
vote
1answer
33 views
Finding users who liked a post
I have a method liked_by and it doesn't seem like appropriate as per Ruby style. I need to do it as less as possible.
...
-2
votes
3answers
68 views
3
votes
1answer
65 views
Countdown AppIndicator
I've decided to translate an old Unity AppIndicator I had written in C to Ruby, so I can practice coding with it (got a little bored with the completely beginner lessons I've been following, which I'...
1
vote
0answers
31 views
Service Connector abstraction for Ruby
My Rails apps need to connect to several external services to perform some functions.
Now, I realize that some of the services I need might also be reused outside Rails (like in Capistrano ...
2
votes
2answers
48 views
Fraction class with documentation
I have never worked with Ruby before, and thought I'd start working on learning it. For my first little implementation, I have created a simple fraction class. It would be nice if someone would check ...
3
votes
2answers
37 views
Ensure continuous date range
I have two arrays
dates = ["20161010","20161013"]
values = [5,3]
which represent dates and a view count. To display them in a graph, I also need the values ...
1
vote
2answers
43 views
Title capitalization exercise from The Odin Project
I just finished the book title class exercise for The Odin Project and I would appreciate some honest feedback for my code. The code is intended to be "test-driven learning", and therefore emulates ...
4
votes
1answer
69 views
Finding the indices where a selected player appears in a list of hashes
I have an array of hashes in a YAML file. When I run the code below it is VERY slow. My YAML pwsarr.count is about 2000.
I am somewhat new to Ruby so I don't know ...
4
votes
1answer
47 views
The Odin Project - Project Ruby: Translating from English to Pig Latin
I just finished the pig latin translator for The Odin Project and I would appreciate some honest feedback for my code. The code is intended to be "test-driven learning", and therefore emulates test ...
1
vote
0answers
30 views
Scoping through embedded document in MongoId
I'm using MongoId in a Rails project. I need to select some products which contain some SKUs which has an embedded document. The models are respectively Product and ...
3
votes
0answers
40 views
Achieving thread safety in a payment service library
I wrote this code a while ago, which is an excerpt of a payment service library:
...
4
votes
1answer
58 views
Marketplace checkout system
I was given the following code challenge as part of an interview process, unfortunately I did not get through to the next stage. Any advice on how I could improve would be very much appreciated.
Here ...
1
vote
1answer
40 views
Skip invalid record and avoid execution break for invalid record
Here is the pseudo code used inside a Rails controller:
...
1
vote
1answer
53 views
Directed Acyclic graph implementation in Ruby on Rails
I have an implementation for a graph node class that I'd like to have function as a directed acyclic graph.
The associations are roughly as follows
...
5
votes
1answer
83 views
Temperature converter app
I'm learning Ruby and as an exercise I decided to build this little temperature converter app (C to F, F to C, F to K, etc). Looking back at it, it's pretty much just a bunch of boilerplate code. Any ...
0
votes
2answers
55 views
Acquiring a hash containing a key and a value
I am new to Ruby and not familiar with a lot of Array features. I feel like this code can be written in a couple of fewer lines.
The idea is: I have a ...
2
votes
1answer
54 views
Project Euler #1: multiples of 3 and 5 Ruby
Total newbie here and wouldn't mind learning from Rubyists to look at how I tried to solve this challenge.
I started with 2 variables n which starts at 0 and total which is an array where I intend to ...
2
votes
1answer
135 views
Analyze Shakespeare's Macbeth parsing XML from web using Nokogiri
This is a simple Ruby program to analyze the number of lines characters speak in Shakespeare's Macbeth using Nokogiri and open-uri to parse a given url containing xml. I wrote this as practice getting ...
0
votes
0answers
18 views
Reading keyboard strokes using multiple input threads
I have a command line program which reads input one character at a time. The following code is working, and if I press three keys at once they will all be printed.
There are four questions here:
why ...
1
vote
3answers
33 views
Binary conversion app
I'm pretty new to ruby and programming in general.
I had an idea for a fun little project that I could use to gain a little experience. I wrote a simple program that takes a 4 bit binary sequence (ie....
1
vote
0answers
46 views
Multi-way Tree organized alphabetically and search in preorder trasversal order
In attempt to create a k-ary or multiway binary tree sorted alphabetically at every deep, I created this class in Ruby to handle the order and search in a recursive way by the ...
4
votes
3answers
54 views
Burning logs - really simple text game
What I have
I am a bit advanced PHP developer, but now I'm going to college where we are learning Ruby. We got the first homework and I did it. But I wanna make great code - so I looked for standards ...
0
votes
2answers
86 views
Most common letter in string, trying to use idiomatic Ruby
The task:
Write a method that takes in a string. Your method should return the
most common letter in the array, and a count of how many times it
appears.
Model solution:
...
1
vote
3answers
85 views
Determines whether a number is a power of 2
The task:
Write a method that takes in a number and returns true if it is a power of 2. Otherwise, return false.
You may want to use the % modulo operation. ...
0
votes
2answers
44 views
Find indices of first pair of numbers that sums to zero
Here is the task from a beginner's course:
Write a method that takes an array of numbers. If a pair of numbers in the array sums to zero, return the positions of those two numbers. If no pair of ...
3
votes
1answer
70 views
Outputting years with no repeated digits
I'm working through a course now, and was tasked with the following:
Write a function, no_repeats(year_start, year_end), which takes a range of years and outputs ...
0
votes
1answer
36 views
Project Euler - #5 smallest multiple (Ruby using a hash table)
Why will this code work for a smaller multiple like 10 but time out for anything over 13? Can this code be revised to work for larger numbers?
(I have an alternate solution but wanted to see if this ...
4
votes
1answer
61 views
A Twitter bot that fetches Forecast.io data and tweets out the current weather with text and emojis
This is my first attempt at creating a Ruby script. I set up a Cron job to run this script every hour. I'm requesting constructive critiques and suggestions for making this better.
Sidenote: I've ...
1
vote
1answer
47 views
Multiway Ruby conditional
I'm a little unhappy with the look of this "flexible" way of dealing with errors from an API in Ruby:
...
1
vote
2answers
50 views
Find numbers with same number of divisors
I tried to resolve this task:
The integers 14 and 15, are contiguous (1 the difference between them,
noticeable) and have the same number of divisors.
...