Questions about Ruby, dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features.

learn more… | top users | synonyms

-3
votes
0answers
34 views

What to choose when designing Dropbox-like infrastructure?

Sapiens, I seek thy help! We're about to begin building the backend infrastructure of our mobile application that is going to store (and organise) files quite a lot like Dropbox. While I did ...
0
votes
0answers
11 views

RubyMotion deployments

I would like to start an application for iOS and Android and I'm considering the option of using RubyMotion for that. I know that you can write Ruby and then deploy to the desired platform. After ...
0
votes
1answer
57 views

Name of a symbol in ruby

I'm very new to ruby. I have to code in ruby at work and a coworker gave me some tests he wrote in ruby. I have some difficulties to understand a line he wrote. We have a class like this: class Port ...
25
votes
3answers
3k views

Are integration tests meant to repeat all unit tests?

Let's say I have a function (written in Ruby, but should be understandable by everyone): def am_I_old_enough?(name = 'filip') person = Person::API.new(name) if person.male? return person....
0
votes
1answer
40 views

Historic (and prehistoric) dates in Ruby

In Ruby, is there a standard class or gem to work with dates that can be - but are not required to be - historical in nature? The dates have precision (to the nearest million years, decade, century, ...
-1
votes
0answers
26 views

Which permanent data storage technology should I use for a simple, but large collection of information in Ruby?

I'm just setting up a Ruby server for my iOS messaging app. The server is for delivering push notifications, and it needs to store some basic user details - a list of devices IDs, an identifier, some ...
1
vote
0answers
53 views

Choosing Between Ruby and Python for a FS Microservice Backend in Node App [closed]

I have been working on a application that up until now has been pure Node. However I am concerned about performance and overhead since the application performs a lot of file system operations (Copy ...
2
votes
0answers
50 views

Best way to build a JSON API coupled with HTML views in a Rails project

I've got a Rails eCommerce project communicating with an iOS app. The iOS app receives JSON data from the Rails back-end, but there's also HTML rendering when a user comes to the project from his ...
8
votes
4answers
200 views

When in your language classes are objects too, does the Liskov substitution principle apply to their interfaces?

According to Wikipedia the Liskov substitution principle states that objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program ...
2
votes
3answers
176 views

Using multiple languages

I currently have a website running PHP laravel. We came to a point where we want to add a user-backend -- where users sign-up and can access functions when logging in. My question is; Is it possible ...
3
votes
1answer
178 views

How to implement a (truly) global variable in a Rails app

How can I best implement a global counter in a Rails API app? (A central component in a system with several.) Basically I have a transaction id I need to increment and roll over past a maximum value. ...
1
vote
1answer
92 views

Ruby: Abusing mixin

I'm currently working with some code that IMO has abused ruby's mixin features. Given that I'm new to ruby, I wonder if MO in IMO is correct or not. My primary question is what makes more sense (and ...
3
votes
1answer
142 views

How do I go about setting up my Sinatra REST API on a server?

I'm an iOS developer primarily. In building my current app, I needed a server that would have a REST API with a couple of GET requests. I spent a little time learning Ruby, and landed on using Sinatra,...
9
votes
1answer
225 views

Python's join seems to focus not on the items to join, but on the symbol, as compared to Ruby or Smalltalk, for a design reason?

I thought one of the cornerstone of OOP is that, we have objects, which are the items we are interested in dealing with, and then we send messages to them. So it may seem natural that, I have a ...
6
votes
1answer
141 views

Testing procedural code

TL;DR. Writing procedural code within a DB transaction. How can I improve design of the code so it's better testable? In my application I have a service object that perform multiple things within the ...
0
votes
2answers
90 views

Using symbols instead of strings in conditions

I usually have if/else conditions which involves comparing values with a constant string. Is it really advantageous to use symbols in such cases or use string. For eg. if status == 'submitted' ... ...
5
votes
4answers
265 views

Ruby: if variable vs if variable.nil?

I'm new to Ruby and I was surprised when I found out that all objects are true apart from nil and false. Even 0 is true. A nice thing about that property of the language is that you can write: if !...
0
votes
1answer
77 views

Does extending a ruby class violate the LSP?

I am reading about SOLID principles. In Ruby tutorials and code samples, I often see subclass extensions like: class House attr_reader :items end class Room < House attr_reader :chair end p ...
0
votes
1answer
115 views

Ruby best practices for Data Access layers

I'm starting my way into Ruby development and have some questions that I hope you can give your best opinion to better design some command line applications I'm developing. What are the best patterns ...
5
votes
2answers
472 views

How are scripting languages compiled?

I know the term "scripting languages" is just a subset of programming languages, but I want to refer to programming languages such as Python and Ruby among others. First of all, why don't we need a ...
0
votes
0answers
66 views

Add-on hot deployable modules for Akka actors?

I'm trying to build a small spray io - akka distributed application targeted towards smaller devices like the Raspberry Pi and BeagleBone Black. The aim is to be able to talk to other devices that ...
1
vote
0answers
66 views

Where did the tradition of new releases on Christmas Day start? [closed]

Perl 6 is being released on Christmas Day this year. I'm familiar with Ruby having a history of releases on Christmas Day, going back as far as Ruby 1.0 in 1996 if not further. However, a quick scan ...
1
vote
0answers
108 views

Terminology - Difference between thread and process and how they manage DB connections

I've been working more with concurrency in Ruby recently, and I keep seeing various articles using "threads" and "process" interchangeably. What are the actual definitions of these terms? Is a ...
3
votes
1answer
349 views

Android App with Ruby Backend Server

I'm working on a personal project to help me branch out and learn some new/different technologies. I'm a .NET programmer but I want to learn Ruby and how to develop Android apps. I have developed ...
0
votes
1answer
260 views

Best way to design a database interface [duplicate]

This is my situation I have a website, mobile client and desktop client. They can all pretty much do the same operations (website might be able to do more now but in the future they might have the ...
1
vote
0answers
156 views

Securing a private API used by an iOS App

I have an app that uses an API server and I do not want to have anything other than it to be able to use that API. I know this isn't totally possible, but I want to do what I can. I don't think my ...
-2
votes
1answer
252 views

Why is Ruby's interpreter so small? [closed]

I noticed that the filesize of Ruby's interpreter seems suspiciously small. I would have expected /bin/dash to be the smallest of all, but is 20x larger than Ruby: Interpreter Bytes -----------...
1
vote
2answers
687 views

Is the time complexity of a while loop with three pointers different than 3 nested for loops?

This program (written in ruby) finds the largest 3 numbers in an array (without sorting the array). It has a while loop with three pointers. My fist instinct, since there is only one loop is to say ...
0
votes
3answers
169 views

Would it be possible to create a language similar to Ruby/Python with static typing that had the speed/memory usage of a compiled C program? [closed]

One of the main drawbacks of Ruby/Python is performance. I understand that they are interpreted and C is compiled. (And there are things like JRuby which do JIT compilation with Ruby). But they never ...
10
votes
8answers
3k views

How do I design a subclass whose method contradicts its superclass? [duplicate]

How do I design a subclass whose method contradicts its superclass? Let's say we have this example: # Example 1 class Scissor def right_handed? true end end class LeftHandedScissor < ...
0
votes
2answers
113 views

Refactoring case-when statement [duplicate]

The Product model which can have 2 price tables. The method price calculates the price of the product based on product's price table which is defined by price_table field. class Product < ...
2
votes
3answers
371 views

Which is the convention in Rails to perform calculations and display the results?

So I'm working on a personal project on Rails to learn more about this framework, and I wanted to add a feature in which the user choose a particular record from the view, and after some calculations ...
1
vote
4answers
654 views

What is the “correct” way to store functions in a database?

Note: Yes, I know that storing functions in databases should be punishable by law. We are developing a financial web application using PostgreSQL, Sinatra and AngularJS. As you may have guessed, a ...
1
vote
3answers
99 views

Replace repeated timestamp with variable in tests

I have couple hundred tests and I work with date/time a lot. In some tests, I aim for output format, elsewhere, I check date ranges. Therefore, my tests have lots of these: FactoryGirl.create(:foo, ...
1
vote
1answer
171 views

What's the best practice for adding a lot of attributes to a Rails model?

So, I'm building an API wrapper gem that works with Spree's Product model. The API provides extensive customization of the data you send to it. I would like a user of the gem to be able to take ...
0
votes
2answers
186 views

Ruby Terminology Question: Implicit Declaration or no declaration at all?

I have a question, because in most serious sources I read, all say the same No variable is ever declared in Ruby, but still I have doubts, because according to what I was taught in my university ...
2
votes
0answers
76 views

Writing a gem supporting compiled languages with Rake. How to test?

I want to create a gem that extends the functionality of Rake, creating commands for compiling .NET code.* Basically, I want to be able to write a Rakefile like this: desc "Build main executable" ...
-1
votes
1answer
127 views

Is obsolete to study older versions of Ruby and RoR? [closed]

I want to study Ruby and RoR for some things I'll have to make, but almost every book, videos or any kind of source I find is outated, where the most current book I could find (link here) is one of ...
0
votes
1answer
143 views

How can I write these services using SOLID and keep them easy to test?

I am trying to write a couple of classes using SOLID principles and having some trouble. The problem is quite simple. I have an application that tracks leads. Leads are created when events are raised ...
1
vote
2answers
476 views

How does the consumer-producer solution work?

I'm only a beginner, and my book doesn't cover this subject. I have researched my problem and found that an implementation of the consumer-producer pattern is the ideal solution, and have Googled it, ...
2
votes
1answer
79 views

BloomFilter in ruby should have k hash functions

I am reading the Bloom Filter implementation written in ruby. It should have k hash functions, but it looks like the same hash function is being used with different seed values. Is this a common way ...
0
votes
1answer
57 views

What would be the return type of a cartesian product of a multiset

I am writing a Multiset in Ruby. The Union, Intersection operations where simple and return a MultiSet. But, I am not sure what the return type of the cartesian product should be, should I return an ...
3
votes
2answers
99 views

Is a guardfile part of the private developers environment or the public OSS project?

Let us say I have an open source project on github. Now I wish to include tools required to develop the project so others can easily contribute. It is hard for me to tell when these tools should be ...
1
vote
1answer
56 views

Create a collection with “average points” of N items from a pool with items of various points

Let's say I have a question pool to generate exams out of it. Each question contains a difficulty from 1 (hard) to 99 (easy). The questions are available in a hash / array (adapt to your favorite ...
1
vote
1answer
94 views

How do rails project know about rake tasks from other repositories

We have a rake task called db:sanity_check which exists in a 'core' repo. Other repositories that we have also show this rake task. But they do not define the rake task. It 'comes' from core' How ...
1
vote
1answer
509 views

Should I use expect or should when writing RSpec specs? [closed]

Please can someone explain to me how I should go about deciding whether to use expect or should syntax for my rspec examples. From my understanding we should no longer be using the 'should' syntax. ...
-1
votes
1answer
371 views

Unevenly distributed random number generation [duplicate]

Let's say I have to generate random number from 1 to 100, however, the probability of each number is not 1/100, but a predefined probability. How to generate that number? I use Ruby/Python.
0
votes
1answer
82 views

Calculate which quantity packages to use based on quantity of bookings

In my app, many appointments can be booked for activities. Each activity has many price packages with a price and a quantity. On showing the cart, I need to work out what combination of packages ...
1
vote
1answer
117 views

Ruby on Rails application interfacing with a Datamax barcode printer [closed]

I am trying to find a standalone way to interface with a Datamax M-Class Mark2 label printer through a Ruby on Rails application. I currently have a solution that is working, which i use javascript to ...
3
votes
0answers
293 views

Splitting up a Rails/Ruby app onto multiple servers

We recently moved a large application to two machines, both running the same codebase. I. Machine A Web server for public facing application Receives web hook call backs from our ESP Handles a ...