Skip to content

Instantly share code, notes, and snippets.

@brittanmcg
Last active December 31, 2015 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brittanmcg/7965083 to your computer and use it in GitHub Desktop.
Save brittanmcg/7965083 to your computer and use it in GitHub Desktop.
This should return any random number or letter passed into the array. It does from what I can tell but it doesn't pass the specs.
class Die
def initialize(labels)
if labels.empty?
raise ArgumentError
end
@labels = labels
end
def sides
@labels.length
end
def roll
random = @labels.shuffle
random[1]
end
end
#test------------------------------------------------------
it 'returns a single letter if one label is passed in' do
random_letter = ('A'..'Z').to_a[rand(26)]
die = Die.new([random_letter])
#end test--------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment