Class: TableScript::Table

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, roller) ⇒ Table

Returns a new instance of Table.



24
25
26
27
28
# File 'lib/tablescript/table.rb', line 24

def initialize( name, roller )
  @name = name
  @roller = roller
  @entries = nil
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



22
23
24
# File 'lib/tablescript/table.rb', line 22

def entries
  @entries
end

Instance Method Details

#build(&blk) ⇒ Object



30
31
32
33
# File 'lib/tablescript/table.rb', line 30

def build( &blk )
  @entries = TableEntryEnvironment.new( @name, @roller )
  @entries.instance_eval( &blk )
end

#lookup(index) ⇒ Object



39
40
41
# File 'lib/tablescript/table.rb', line 39

def lookup( index )
  @entries.lookup( index )
end

#random_entryObject



35
36
37
# File 'lib/tablescript/table.rb', line 35

def random_entry
  @roller.rollD( @entries.die_to_roll )
end

#rollObject



43
44
45
# File 'lib/tablescript/table.rb', line 43

def roll
  @entries.reroll
end

#roll_and_ignore_duplicates(times, args) ⇒ Object



47
48
49
# File 'lib/tablescript/table.rb', line 47

def roll_and_ignore_duplicates( times, args )
  @entries.reroll_and_ignore_duplicates( times, args )
end