Class: TableScript::Table
- Inherits:
-
Object
- Object
- TableScript::Table
- Defined in:
- lib/tablescript/table.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
- #build(&blk) ⇒ Object
-
#initialize(name, roller) ⇒ Table
constructor
A new instance of Table.
- #lookup(index) ⇒ Object
- #random_entry ⇒ Object
- #roll ⇒ Object
- #roll_and_ignore_duplicates(times, args) ⇒ Object
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
#entries ⇒ Object (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_entry ⇒ Object
35 36 37 |
# File 'lib/tablescript/table.rb', line 35 def random_entry @roller.rollD( @entries.die_to_roll ) end |
#roll ⇒ Object
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 |