Class: Precipitation

Inherits:
Object
  • Object
show all
Defined in:
lib/precipitation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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

Returns:

  • (Boolean)


9
10
11
# File 'lib/precipitation.rb', line 9

def rainbow?
  @chance_for_rainbow > 0 && @roller.roll(100) <= @chance_for_rainbow
end

#to_sObject



13
14
15
# File 'lib/precipitation.rb', line 13

def to_s
  "[#{@name}; rainbow: #{rainbow?}]"
end