Class: AsciiMath::SymbolTableBuilder
- Inherits:
-
Object
- Object
- AsciiMath::SymbolTableBuilder
- Defined in:
- lib/asciimath/symbol_table.rb
Instance Method Summary collapse
- #add(*args) ⇒ Object
- #build ⇒ Object
-
#initialize ⇒ SymbolTableBuilder
constructor
A new instance of SymbolTableBuilder.
Constructor Details
#initialize ⇒ SymbolTableBuilder
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 |
#build ⇒ Object
21 22 23 |
# File 'lib/asciimath/symbol_table.rb', line 21 def build @table.dup.freeze end |