Module: Tablescript::Api

Defined in:
lib/tablescript/api.rb

Overview

Api

Instance Method Summary collapse

Instance Method Details

#lookup(path, roll) ⇒ Object



46
47
48
# File 'lib/tablescript/api.rb', line 46

def lookup(path, roll)
  LookupStrategy.new(Library.instance.table(path.to_s), roll).value
end

#namespace(name, &blk) ⇒ Object



23
24
25
26
# File 'lib/tablescript/api.rb', line 23

def namespace(name, &blk)
  generator = NamespaceGenerator.new(Library.instance.root.namespace(name.to_s))
  generator.instance_eval(&blk)
end

#roll_on(path) ⇒ Object



34
35
36
# File 'lib/tablescript/api.rb', line 34

def roll_on(path)
  RollStrategy.new(Library.instance.table(path.to_s)).value
end

#roll_on_and_ignore(path, *args) ⇒ Object



38
39
40
# File 'lib/tablescript/api.rb', line 38

def roll_on_and_ignore(path, *args)
  RollAndIgnoreStrategy.new(Library.instance.table(path.to_s), RpgLib::RollSet.new(*args)).value
end

#roll_on_and_ignore_duplicates(path, times) ⇒ Object



42
43
44
# File 'lib/tablescript/api.rb', line 42

def roll_on_and_ignore_duplicates(path, times)
  RollAndIgnoreDuplicatesStrategy.new(Library.instance.table(path.to_s), times).values
end

#table(name, &blk) ⇒ Object



28
29
30
31
32
# File 'lib/tablescript/api.rb', line 28

def table(name, &blk)
  root_namespace = Library.instance.root
  table = Table.new(name.to_s, root_namespace, &blk)
  root_namespace.add(table)
end