Last active
December 20, 2015 12:09
-
-
Save MrBean83/6129399 to your computer and use it in GitHub Desktop.
"Die Class 2: Arbitrary Symbols"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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