Skip to content

Instantly share code, notes, and snippets.

@MrBean83
Last active December 20, 2015 12:09
Show Gist options
  • Select an option

  • Save MrBean83/6129399 to your computer and use it in GitHub Desktop.

Select an option

Save MrBean83/6129399 to your computer and use it in GitHub Desktop.
"Die Class 2: Arbitrary Symbols"
class Die
attr_accessor :labels
def initialize(labels)
unless labels.length > 0
raise ArgumentError.new("Where's your strings?")
end
@labels = labels
end
def sides
@labels.length
end
def roll
@labels[rand(@labels.length)]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment