Class: Roll

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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