Class: AsciiMath::SymbolTableBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/asciimath/symbol_table.rb

Instance Method Summary collapse

Constructor Details

#initializeSymbolTableBuilder

Returns a new instance of SymbolTableBuilder.



3
4
5
# File 'lib/asciimath/symbol_table.rb', line 3

def initialize()
  @table = {}
end

Instance Method Details

#add(*args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/asciimath/symbol_table.rb', line 7

def add(*args)
  raise 'Insufficient arguments' if args.length < 3

  entry = {}
  if args.last.is_a?(Hash)
    entry.merge!(args.pop)
  end
  entry[:type] = args.pop
  entry[:value] = args.pop

  entry.freeze
  args.each { |name| @table[name.freeze] = entry }
end

#buildObject



21
22
23
# File 'lib/asciimath/symbol_table.rb', line 21

def build
  @table.dup.freeze
end