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

-6
votes
0answers
23 views

How to align a nucleotide sequence against a set of them in a database? [closed]

How to align a nucleotide sequence against a set of them in a database? Need a sample Python , Java or Ruby code showing the alignment of an input 1000 bp sequence against a set of them. I could find ...
0
votes
2answers
77 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 < ...
-4
votes
1answer
182 views

Why is one language with elegant easy to read syntax as fast as one with the verbosity or explicitness? [closed]

There are 2 distinct types of programming language design categories in my eyes. We have C++/Java/Rust/C# languages on this side, Fast for the most part but also a bit verbose or explicit. On this ...
0
votes
0answers
33 views

How best to define classes declaratively in Ruby

Coming from a Perl background I greatly appreciate the Moose/Moo based approach to defining class constructors declaratively. What I mean by that is that with Moose we declare the characteristics of ...
2
votes
3answers
126 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
0answers
180 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
57 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
0answers
59 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
77 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 ...
1
vote
0answers
69 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
80 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 ...
2
votes
0answers
78 views

Is this code solid? If it's not why not? And how should the dependencies be managed? [closed]

I am very interested in following the SOLID principles of writing code, but for the life of me I consistently run into more questions than answers. One of the questions I have now related to the code ...
0
votes
1answer
140 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
281 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
61 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
40 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 ...
2
votes
2answers
71 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
46 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
60 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
159 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
186 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
67 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 ...
0
votes
1answer
68 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
141 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
168 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 ...
8
votes
2answers
347 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 ...
28
votes
2answers
3k 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
179 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 ...
2
votes
2answers
326 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 = ...
0
votes
2answers
343 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
108 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
2k 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 ...
3
votes
1answer
116 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 ...
0
votes
2answers
232 views

What happened to VM based deployments?

Watched some MountainWest RubyConf 2014 talks and noticed an interesting theme. Many dynamic programming environments back in the old days used to be self-contained VM images, e.g. SmallTalk, ...
-3
votes
1answer
208 views

Is there a purely technical term for 'monkey patching' [closed]

EDIT The original title of the question was Is there a non-derogatory term for 'monkey patching'. As I have learned that the term is actually not derogatory, or is at least not meant to be, I changed ...
0
votes
1answer
199 views

JSON - Ruby objects key naming

Ruby object has method/property: def tentakles_count 8 end JavaScript object has key/property: { justEnough: true } Now, when JavaScript gets serialised ruby object via XHR or WebSocket, ...
1
vote
2answers
245 views

Need advice on design in Ruby On Rails

For personal educational purposes I am making a site for a conference. One of the object that exist in a conference is a session, which has different states and in each state it has slightly different ...
1
vote
1answer
220 views

Why many Ruby gems won't work on Windows [duplicate]

Most of the gems out there work fine on *nix but not on Windows. First I tried WySQL2, then dosu which shows incompatibility with Ruby 2.0. I tried things on github issues, but no luck. I never had ...
2
votes
2answers
116 views

How to check robustness in a service that includes multiple points of failure in workflow, including FTP

As part of my workflow, I need to do all these steps in one transaction - I need to ftp files to 2 different FTP servers. - There is also a spreadsheet that gets generated which needs to be FTP'ed. ...
2
votes
4answers
373 views

Test Doubles, Mocks and Stubs - when not to use & why, for Ruby, Rspec

I've learned about mocking and stubbing and I've seen how they can help me create great test suites that run blindingly fast and thus speed up my development process hugely. However I've also seen ...
-2
votes
1answer
6k views

Advantages and disadvantages of PHP/Ruby [closed]

I've been a front-end developer for about two years now, and I'm attempting to break into the server side of things. Ideally I'd like to work for a startup social network on the back-end side so I ...
2
votes
2answers
95 views

Auxiliary space complexity of map vs map!

I'm curious about the difference in space complexity between map and map! in ruby. If I have the methods: def mult_by_two(arr) arr.map {|i| i * 2 } end def mult_by_two!(arr) arr.map! {|i| i * 2 ...
32
votes
11answers
5k views

Is it okay to make coding style changes on an open source project that doesn't follow best practices?

Recently, I came across a number of open source Ruby (or majority of it was Ruby) projects on GitHub that when checked with a code analyzing tool like Rubocop, create a lot of offenses. Now, most of ...
2
votes
1answer
67 views

scoping concern when dealing with coupling

I'm learning ruby (and OOP in the process) and I find keep having to write the same patterns when logging progress so I want to wrap this up in a logging library that my other code can then just pass ...
0
votes
6answers
420 views

How do I explain a ruby method with a real-world analogy? [closed]

I am looking for a good analogy to help the concept of a method in ruby stick in my head. When I truly understand a concept, an image flashes in my mind that relates something physical to the abstract ...
0
votes
0answers
628 views

Ruby module namespacing advice

in my current project have: module Stats class Site ... end class Product def initialize(product_id) @product_id = product_id end end class Profile ... end end ...
1
vote
1answer
202 views

Dealing with 'dirty' Ruby on Rails client

I had to leave a startup about a month ago because of lack of funding. Basically, this client wanted an application to allow contractors to create, update, read, and delete yardsigns. Straight forward ...
1
vote
2answers
172 views

In Ruby, change global in thread safe block

In Ruby, I have a use case for a few common configuration options, e.g. NOOP, TRACE, SILENT. Right now I am using local vars instead of globals and passing them around all over the place and it's a ...
0
votes
1answer
614 views

ruby for desktop app or web app development [closed]

i am a beginner to ruby . i just did some minor research about why RUBY ? why choose RUBY ? whats new in it. Whenever i do type in a word RUBY in google search there comes a suggestion like RUBY on ...
19
votes
3answers
1k views

Why do so many languages treat numbers starting with 0 as octal?

I've read Where are octals useful? and it seems like octals are something that were once upon a time useful. Many languages treat numbers preceding with a 0 as octal, so the literal 010 is actually ...