module BCDice::Arithmetic
Public Class Methods
eval(source, round_type)
click to toggle source
四則演算を評価する
@param source [String] @param round_type [Symbol] @return [Integer, nil] パースできない式やゼロ除算が発生した場合にはnilを返す
# File lib/bcdice/arithmetic.rb, line 14 def eval(source, round_type) node = Parser.parse(source) node&.eval(round_type) rescue ZeroDivisionError nil end