Class: RpgLib::Parser::DiceParser
- Inherits:
-
Object
- Object
- RpgLib::Parser::DiceParser
- Defined in:
- lib/rpg_lib/parser/dice_parser.rb
Overview
DiceParser
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize ⇒ DiceParser
constructor
A new instance of DiceParser.
- #parse(dice) ⇒ Object
Constructor Details
#initialize ⇒ DiceParser
Returns a new instance of DiceParser.
9 10 11 12 |
# File 'lib/rpg_lib/parser/dice_parser.rb', line 9 def initialize @parser = DiceExpressionParser.new @cache = {} end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
7 8 9 |
# File 'lib/rpg_lib/parser/dice_parser.rb', line 7 def parser @parser end |
Instance Method Details
#parse(dice) ⇒ Object
14 15 16 17 |
# File 'lib/rpg_lib/parser/dice_parser.rb', line 14 def parse(dice) return @cache[dice] if @cache.key?(dice) parse_new_dice(dice) end |