Class: Roll
- Inherits:
-
Object
- Object
- Roll
- Defined in:
- lib/cardtrick/roll.rb
Instance Attribute Summary collapse
-
#dice ⇒ Object
readonly
Returns the value of attribute dice.
Instance Method Summary collapse
- #each(&b) ⇒ Object
-
#initialize(*d) ⇒ Roll
constructor
A new instance of Roll.
- #map(&b) ⇒ Object
Constructor Details
#initialize(*d) ⇒ Roll
3 4 5 |
# File 'lib/cardtrick/roll.rb', line 3 def initialize *d @dice = [d].flatten end |
Instance Attribute Details
#dice ⇒ Object (readonly)
Returns the value of attribute dice.
2 3 4 |
# File 'lib/cardtrick/roll.rb', line 2 def dice @dice end |
Instance Method Details
#each(&b) ⇒ Object
7 8 9 10 |
# File 'lib/cardtrick/roll.rb', line 7 def each &b @dice.each { |e| b.call(e) } return nil end |
#map(&b) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cardtrick/roll.rb', line 12 def map &b h = {} each { |e| ee = Cardtrick[e]; k = ee.key v = ee.map { |eee| b.call(eee) } h[k] = v } return h end |