Class: DiceBag::Parser

Inherits:
Parslet::Parser
  • Object
show all
Defined in:
lib/dicebag/parser.rb

Overview

This class parses the dice string into the individual components. To understand this code, please refer to the Parslet library’s documentation.

Instance Method Summary collapse

Instance Method Details

#parse(dstr) ⇒ Object

We override the #parse method, so that we can assure that we always return an Array.



10
11
12
13
14
15
16
# File 'lib/dicebag/parser.rb', line 10

def parse(dstr)
  result = super dstr

  result = [result] unless result.is_a? Array

  result
end