Class: Tabletop::FudgeDie
Overview
A FudgeDie is a kind of three-sided Die that has a value of either 0, 1, or -1.
Instance Attribute Summary
Attributes inherited from Die
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ FudgeDie
constructor
A new instance of FudgeDie.
- #roll ⇒ Object
-
#to_s ⇒ Object
Returns either “[-]”, “[ ]”, or “[+]”, depending on @value.
Methods inherited from Die
#<=>, new_from_string, #to_int
Constructor Details
#initialize(params = {}) ⇒ FudgeDie
Returns a new instance of FudgeDie.
68 69 70 |
# File 'lib/tabletop/randomizers.rb', line 68 def initialize(params = {}) super(sides: 3, value: params[:value]) end |
Instance Method Details
#roll ⇒ Object
71 72 73 |
# File 'lib/tabletop/randomizers.rb', line 71 def roll @value = rand(sides)-1 end |
#to_s ⇒ Object
Returns either “[-]”, “[ ]”, or “[+]”, depending on @value
76 77 78 |
# File 'lib/tabletop/randomizers.rb', line 76 def to_s "[#{['-', ' ', '+'][@value+1]}]" end |