Questions tagged [ruby]
Ruby is a multi-platform, open-source, dynamic, object-oriented, interpreted language created by Yukihiro Matsumoto (Matz) in 1993.
1,612 questions
3
votes
1
answer
62
views
Ruby Array#own_uniq method
I have implemented my own version of Ruby's Array uniq-method (Ruby docs - Class array) as a monkey patch on Array.
Method-impl.:
...
4
votes
2
answers
110
views
Ruby: Implement an 'add_thirty_days'-method
Task:
Implement a method, which receives an array of strings as argument. The strings are dates in the format "MM**DD**YYYY". For example: "11**03**2024".
Add 30 to each of the ...
6
votes
2
answers
438
views
(Codewars) Goldbach's Conjecture (by @rsalgado) in Ruby
Link to kata: linkRank: 6 kyuKata author: @rsalgado
I have been recently learning Ruby-lang and have been attempting to solve the following kata from Codewars involving Goldbach's Conjecture:
...
4
votes
2
answers
240
views
Ruby Array#own_shuffle method
I have tried to implement the Array-shuffle method myself. Haven't had a look on some similar algorithm-examples by purpose and tried to figure out something myself.
The actual Array-extension:
...
4
votes
1
answer
202
views
Fetching data from a REST-API then converting to CSV
I like to have a script which fetches data from a REST-API then writes the data into a CSV file.
Here's what I've got so far (prototype, using a publicly accessible dummy-API):
...
2
votes
1
answer
67
views
Ruby 'mkdir_reports'-script for creating folder-/file-structure automated
Initial situation: Each week a nested folder-/file-structure has to be created. Content is added to the files. Afterward the structure is copied to a shared-folder for long-time documentation.
Example:...
5
votes
3
answers
123
views
Ruby: Check for Palindrome (as Monkey-Patch on String-class)
I have written a method, which checks for Palindrome and attached it to the String-class.
Here's the code:
...
3
votes
0
answers
48
views
Using Pundit Policy Scopes with Searchkick Results
We are using Searchkick to run our elasticsearch and Pundit to authorize users for specific actions. Below is our module SearchkickScope that does it's best to ...
2
votes
1
answer
70
views
Rails session after migrate from PHP (improved)
previusly I make a post for Session Logic for User Verification in Rails Migration.
Now the improvement version following advice of the comments is here.
The problem was the use of `` for executing in ...
3
votes
1
answer
106
views
Session Logic for User Verification in Rails Migration
This is a logic to create sessions on RoR 7.1.2 based on the last version of the website which was in vanilla PHP, with the upgrade I have to deal with the users that were already signed up but not ...
1
vote
1
answer
112
views
Advent of Code Day 8
The task
A file similar to the following is provided.
...
1
vote
1
answer
68
views
Ruby-function for reading, parsing a text-file, removing data-duplicates
Task description:
Implement a generate_unique_phone_numbers function.
The function shall parse the given text-file.
Content-example:
...
3
votes
3
answers
167
views
Print last lines of file
Task
Write a Ruby function, which accepts a path to a text file and returns a string consisting of the last n lines in reversed order, separated by commas.
Example input file:
...
1
vote
1
answer
162
views
The simple calculator in Ruby
I wrote the simple calculator in Ruby. This is my first program in this language. I've switched recently from Python to Ruby. What do you think about my work? Thanks
...
1
vote
4
answers
256
views
Ruby FizzBuzz using the ternary operator two times
Task: Implement a function which loops from 1 to 100 and prints "Fizz" if the counter is divisible by 3. Prints "Buzz" if the counter is divisible by 5 and "FizzBuzz", ...