Tagged Questions
0
votes
1answer
34 views
Ruby Game of Life with matrices
A little while ago I wrote this implementation of Conway's Game of Life in Ruby. It's based on this Game of Life in APL video, which I think is rather elegant, though a bit dense. Feel free to give ...
1
vote
2answers
123 views
Ruby implementation of Conway's Game of Life
I'm just starting with Ruby and decided to do two different implementations of Conway's Game of Life. In this first one I'm not using cells as a separate class and instead just track everything as a ...
2
votes
1answer
259 views
Encoding special characters in URLs with Ruby
I have the following Ruby code snippet:
url = "http://somewiki.com/index.php?book=#{author}:#{title}&action=edit"
encoded = URI.encode(url)
encoded.gsub(/&/, "%26").sub(/%26action/, ...
2
votes
1answer
128 views
Which of these implementations is considered cleaner?
I've got a simple sinatra webapp that pulls data from Pinboard's RSS api, parses the info, and re-displays it. There are 4 tasks I need to perform with the data:
I need to remove all instances of a ...
2
votes
1answer
109 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 ...
3
votes
3answers
1k views
Ruby function to join array with commas and a conjunction
Should take an array such as ['dog', 'cat', 'bird', 'monkey'] and return 'dog, cat, bird and monkey'.
Looking for a more elegant solution.
def self.english_join(array)
return nil if array.nil?
...
0
votes
1answer
110 views
What if any design issues are there in this method of loading configuration data from YAML in Ruby?
I am actually pretty excited about this approach, but for sanity's sake I wanted to hear some thoughts on others on my strategy here. My basic goal is to parse a YAML file and recursively create ...
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 ...