Module: Crapshoot
- Defined in:
- lib/crapshoot.rb,
lib/crapshoot/result.rb,
lib/crapshoot/scanner.rb,
lib/crapshoot/version.rb,
lib/crapshoot/evaluator.rb,
lib/crapshoot/postfixer.rb,
lib/crapshoot/parser/scan.rb,
lib/crapshoot/tokens/base.rb,
lib/crapshoot/tokens/series.rb,
lib/crapshoot/tokens/constant.rb,
lib/crapshoot/tokens/arithmetic.rb
Defined Under Namespace
Modules: Parser, Tokens Classes: Evaluator, Postfixer, Result, Scanner
Constant Summary collapse
- VERSION =
'0.5.0'
Class Method Summary collapse
-
.roll(expression) ⇒ Crapshoot::Result
Rolls dice for the given expression.
Class Method Details
.roll(expression) ⇒ Crapshoot::Result
Rolls dice for the given expression.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/crapshoot.rb', line 12 def self.roll(expression) scanner = Scanner.new postfixer = Postfixer.new evaluator = Evaluator.new tokens = scanner.parse expression postfix_tokens = postfixer.postfixify tokens result = evaluator.evaluate postfix_tokens return result end |