Sha256: f0e3d49c7e8a513877a01a89f10c9fb96947675b6c53e936a1529137225f2ba1

Contents?: true

Size: 319 Bytes

Versions: 7

Compression:

Stored size: 319 Bytes

Contents

require 'dice'
module Gm
  module Notepad
    module Evaluators
      module DiceEvaluator
        def self.call(text:, fallback: text)
          if parsed_text = Dice.parse(text.strip)
            parsed_text.evaluate.to_s
          else
            fallback.to_s
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gm-notepad-0.0.18 lib/gm/notepad/evaluators/dice_evaluator.rb
gm-notepad-0.0.17 lib/gm/notepad/evaluators/dice_evaluator.rb
gm-notepad-0.0.16 lib/gm/notepad/evaluators/dice_evaluator.rb
gm-notepad-0.0.15 lib/gm/notepad/evaluators/dice_evaluator.rb
gm-notepad-0.0.14 lib/gm/notepad/evaluators/dice_evaluator.rb
gm-notepad-0.0.13 lib/gm/notepad/evaluators/dice_evaluator.rb
gm-notepad-0.0.12 lib/gm/notepad/evaluators/dice_evaluator.rb