Class: Gm::Notepad::LineEvaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/gm/notepad/line_evaluator.rb

Overview

Responsible for recording entries and then dumping them accordingly.

Constant Summary collapse

TABLE_NAME_REGEXP =
%r{(?<table_name_container>\{(?<table_name>[^\{\}]+)\})}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_registry:) ⇒ LineEvaluator

Returns a new instance of LineEvaluator.



8
9
10
# File 'lib/gm/notepad/line_evaluator.rb', line 8

def initialize(table_registry:)
  @table_registry = table_registry
end

Instance Attribute Details

#table_registryObject (readonly)

Returns the value of attribute table_registry.



11
12
13
# File 'lib/gm/notepad/line_evaluator.rb', line 11

def table_registry
  @table_registry
end

Instance Method Details

#call(line:, expand_line: true) ⇒ Object



14
15
16
17
18
# File 'lib/gm/notepad/line_evaluator.rb', line 14

def call(line:, expand_line: true)
  return line unless expand_line
  text = parse_table(text: line)
  parse_dice(text: text)
end