Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. http://www.ruby-lang.org/ Knowledge Base: API (APIdock) API (1.8) API (1.9) Try Ruby
1
vote
1answer
36 views
Ruby code refactoring
I have n-times similar statements
if trigger_data.tt_closed
unless trouble_ticket.changes.key?(:status)
@run = 0
break
end
unless ...
0
votes
0answers
20 views
my first gem as a newbie rubyist
Good sunny afternoon,
I have made my first gem! Hooraah, it is very simple and fuses httparty gem with ebay xml api to get categories from ebay.
The api keys etc are loaded from ENV variables.
...
1
vote
1answer
53 views
File Renaming with Ruby
This is a minimal little utility that I've found useful while reorganizing my music and book libraries. Any issues you can see? Anything I could be doing better or more elegantly? Anyone wanna take a ...
1
vote
2answers
62 views
Bubble sort algorithm in Ruby with tests
As a matter of practice, I tried implementing a bubble sort algorithm in Ruby. I'm especially interested in creating clean DRY and KISS code and keeping things readable, but efficient. Any hints to ...
2
votes
1answer
113 views
Code review request for git-backup
After reading this stackoverflow question http://stackoverflow.com/questions/2129214/backup-a-local-git-repository/10458663 I decided to write a backup utility for local git repositories.
The result ...
2
votes
2answers
69 views
Correctness of a minimal parallel workers queue in Ruby
I've programmed a minimal parallel workers queue in Ruby, and I wanted to know if it's correct, and if there are simpler ways of implementing it.
I'm aware of the existence of MonitorMixin, but it ...
3
votes
1answer
88 views
Greedy algorithm in Ruby - any suggestions?
Here is my implementation of the greedy algorithim in Ruby. Do you have any suggestions?
class Greedy
def initialize(unit, total, *coins)
@total_coins = 0
@unit = unit
@total = total
...
3
votes
2answers
77 views
Make these Methods Better
How can I make these methods better?
Range.class_eval do
def addto_begin(x)
return self.begin + x..self.end
end
def addto_end(x)
return self.begin..self.end+x
end
end
...
1
vote
2answers
55 views
Rails: “somefile.html.erb” -How can I make this code more concise and elegant?
Hi Im letting the users upload an file from the browser into my rails app. using paperclip gem.
Once the file is uploaded it gets saved into the filesystem. When the user then goes in and the "show" ...
2
votes
1answer
46 views
Ruby A Clean Way Compare Hash Members to Other Hash Members
I've written a script that deletes a member of a hash if an array within the has contains all the other elements of another array within the same hash.
It works but it looks a little messy. Is there ...
1
vote
3answers
71 views
Refactor this Ruby on Rails code
Im wondering how could I refactor this code. It may look a little reiterative and probably there's a shorter method to accomplish the same.
def self.location(distance=100,location)
if ...
2
votes
1answer
82 views
Is this good Ruby?
This is the "codebreaker" game in Ruby, tell me what I can make better!
#!/usr/bin/env ruby
class Sequence
attr_accessor :guess, :code
def initialize
puts "Type the difficulty level you ...
2
votes
2answers
117 views
Avoiding nested if statements
I occasionally find myself bumping into code like this (either in other projects or banging out initial prototypes myself):
if @product.save
if current_member.role == "admin"
redirect_to ...
1
vote
1answer
81 views
ruby chess engine
i am new to stackexchange; second post here..a repost of the incorrectly-posting of this question elsewhere in fact. i would like help/advice on my code.
here's the backstory. last week, i decided to ...
1
vote
1answer
113 views
Anything Wrong With this Program?
#!/usr/bin/env ruby
require 'open-uri'
print "URL: "
add = gets
puts "Info from #{add}"
begin
open(add) do |f|
puts "Fetching images..."
puts "Fetching links..."
puts "Fetching div ...