1
vote
2answers
45 views

How can I make an easy to understand subtraction accumulator?

I'm currently following the tutorials over at RubyMonk, and one of the problems I need to solve is to write a subtract function that would meet these conditions: invoking subtract(4, 5) should ...
3
votes
1answer
68 views

Count comments and lines of code in ruby

Hi I wrote a small script as an answer for a stack overflow question, that counts lines of code and comments (in C and C++ style). f = File.open("test.txt") loc = 0 comments = 0 while line = f.gets ...
1
vote
0answers
41 views

Best Practices: Assigning a class to a variable for readability in Ruby

I recently found myself writing the following: task :spec do |t, args| require_relative 'spec/helper' helper = Library::Specs::Helper helper.start_coverage if condition ...
4
votes
3answers
260 views

Ruby style review

I am about to start a very large project in Ruby. To get myself in the Ruby mindset I have been doing all of my homework and other side work in Ruby. I am hoping that some of you who know Ruby very ...
5
votes
1answer
315 views

Is this an appropriate class design for the strategy pattern in Ruby?

I am fairly satisfied with my solution here but I would definitely appreciate any constructive criticism of my style and design. The basic idea is to use the strategy pattern to simplify assembling a ...
6
votes
2answers
120 views

String substitutions in ruby and coding style

I wrote a short ruby script to generate various screenshots, and event though I am not completely new to ruby I rarely use it. Full script (41 LOC): https://gist.github.com/1229115 The string ...