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

0
votes
1answer
46 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 ...
-2
votes
0answers
36 views

How much poppler-utils is scalable?

We need to process large number of PDFs simultaneously to extract text, images and create htmls. We have been using poppler-utils for PDF processing and Ruby for making system calls to poppler-util ...
2
votes
1answer
58 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 ...
9
votes
1answer
213 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
118 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
67 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
172 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
71 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
0answers
63 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
399 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
48 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
64 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
70 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 ...
2
votes
1answer
252 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
180 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
135 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
209 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
590 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
151 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
0answers
40 views

Is listing Types in documentation a code smell

I'm documenting a ruby application and looking closely at YARD. I like the increased structure provided over RDoc, but I'm unsure about the Type declaration. In YARD, you can do something like ...
0
votes
2answers
109 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
257 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
473 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
87 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
137 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
138 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
74 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
120 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
409 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
78 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
54 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
93 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
55 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
84 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
361 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
308 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
80 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
97 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
249 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 ...
1
vote
0answers
267 views

Run RSpec from within a ruby script while refreshing all ruby configs etc

I'm working with a very large project with tons of established tests that include some reasonably complicated environment setups and what not. I've recently run into a situation testing some ...
9
votes
2answers
384 views

Why don't Python and Ruby make a distinction between declaring and assigning a value to variables?

Two of the most popular dynamically typed scripting languages, Python and Ruby, do not make a distinction in syntax between the declaration of a variable and assignation of a value to it. That is in ...
33
votes
2answers
4k views

Do modern languages still use parser generators?

I was researching about the gcc compiler suite on wikipedia here, when this came up: GCC started out using LALR parsers generated with Bison, but gradually switched to hand-written ...
0
votes
1answer
287 views

Refactoring a Single Rails Model with large methods & long join queries trying to do everything

I have a working Ruby on Rails Model that I suspect is inefficient, hard to maintain, and full of unnecessary SQL join queries. I want to optimize and refactor this Model (Quiz.rb) to comply with ...
3
votes
2answers
585 views

What kind of exception to ask for out of range arguments?

What type of exception should I throw? I have a console class which describes rectangle of cells which a user can index by passing in a coordinate: width, height = 80, 25 console = ...
1
vote
3answers
511 views

How can I rank teams based off of head to head wins/losses

I'm trying to write an algorithm (specifically in Ruby) that will rank teams based on their record against each other. If a team A and team B have won the same amount of games against each other, then ...
0
votes
1answer
176 views

Android -> Ruby Server Interface -> Mongodb

I've been wrecking my brain about this for a few days. I'll run my scenario by you and hopefully you can help me. In my head this is how it goes: I have an Android App. I want my Android App to make ...
1
vote
2answers
4k views

Why doesn't Ruby have implicit conversion of Fixnum into String?

Ruby normally makes things easy. However, it doesn't allow implicitely converting a number to a string: 2.0.0p247 :010 > "a"+1 TypeError: no implicit conversion of Fixnum into String Why is this ...
4
votes
1answer
158 views

What does it mean that file IO binary flag is only relevant on Windows

I was reading a question and one of the comments mentioned that "The binary flag is only relevant on Windows". Given the context of the question and answer, I interpret this statement as on ...