Class: Precipitation
- Inherits:
-
Object
- Object
- Precipitation
- Defined in:
- lib/precipitation.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(info, dieroller) ⇒ Precipitation
constructor
A new instance of Precipitation.
- #rainbow? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(info, dieroller) ⇒ Precipitation
Returns a new instance of Precipitation.
3 4 5 6 7 |
# File 'lib/precipitation.rb', line 3 def initialize(info, dieroller) @name = info.name @chance_for_rainbow = info.chance_of_rainbow @roller = dieroller end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/precipitation.rb', line 2 def name @name end |
Instance Method Details
#rainbow? ⇒ Boolean
9 10 11 |
# File 'lib/precipitation.rb', line 9 def rainbow? @chance_for_rainbow > 0 && @roller.roll(100) <= @chance_for_rainbow end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/precipitation.rb', line 13 def to_s "[#{@name}; rainbow: #{rainbow?}]" end |