Questions tagged [ruby]
Ruby is a multi-platform, open-source, dynamic, object-oriented, interpreted language created by Yukihiro Matsumoto (Matz) in 1993.
1,608 questions
4votes
1answer
188views
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): ...
2votes
1answer
64views
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:...
5votes
3answers
91views
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: ...
3votes
0answers
41views
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 ...
1vote
1answer
58views
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 ...
3votes
1answer
90views
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 ...
1vote
1answer
100views
Advent of Code Day 8
The task A file similar to the following is provided. ...
1vote
1answer
61views
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: ...
2votes
3answers
140views
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: ...
1vote
1answer
150views
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 ...
1vote
4answers
207views
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", ...
1vote
1answer
95views
Changes hash to allocate values as directed
Let's say you have a hashmap of sub-systems that a spaceship is currently directing power to and a second hash of sub-systems where the power should now be directed to. Create a function that returns ...
6votes
1answer
479views
Write a simple, clean error message without a backtrace and exit on failure
I want to write on failure to either STDOUT or STDERR a clean, simple error message for the user, without the (verbose) ...
2votes
2answers
184views
Ruby SFTP client
I'm on Ruby for three weeks and now I want to learn more. Please review this SFTP client and suggest any necessary changes. ...
3votes
1answer
62views
Solution to Codejam 2022 1C (Letter Blocks) in Ruby
The following is my solution to the Letter Blocks problem from Codejam 2022: https://codingcompetitions.withgoogle.com/codejam/round/0000000000877b42/0000000000afe6a1. Problem It is a rainy day, so ...