Class: Plurimath::Asciimath::Constants
- Inherits:
-
Object
- Object
- Plurimath::Asciimath::Constants
- Defined in:
- lib/plurimath/asciimath/constants.rb
Constant Summary collapse
- TABLE_PARENTHESIS =
{ "ᑕ": "ᑐ", "ℒ": "ℛ", "[": "]", "(": ")", }.freeze
- PARENTHESIS =
{ "ᑕ": "ᑐ", "ℒ": "ℛ", "(": ")", "{": "}", "[": "]", }.freeze
- UNARY_CLASSES =
%w[ underbrace overbrace underline arccos arcsin arctan ubrace obrace cancel tilde floor ceil ddot coth csch sech sinh tanh cosh sqrt norm text sec sin tan cos exp gcd glb lcm lub cot csc det dim max min abs bar dot hat vec ul ln ].freeze
- FONT_STYLES =
%w[ mathfrak mathcal mathbb mathsf mathtt mathbf bbb bb rm fr cc sf tt ii ].freeze
- SUB_SUP_CLASSES =
%w[lim log].freeze
- TERNARY_CLASSES =
%w[prod oint sum int].freeze
- SPECIAL_BOLD_ALPHABETS =
%w[ZZ RR QQ NN CC].freeze
- BINARY_CLASSES =
%w[underset stackrel overset frac root].freeze
- SKIP_INPUT_PARENS =
["[", "]", "{", "}", "(", ")", "(:", ":)"].freeze
Class Method Summary collapse
- .named_hash(hash_or_array, name_key) ⇒ Object
- .parens_symbols ⇒ Object
- .precompile_constants ⇒ Object
- .symbols_array ⇒ Object
Class Method Details
.named_hash(hash_or_array, name_key) ⇒ Object
97 98 99 |
# File 'lib/plurimath/asciimath/constants.rb', line 97 def named_hash(hash_or_array, name_key) hash_or_array.each_with_object({}) { |d, i| i[d] = name_key } end |
.parens_symbols ⇒ Object
105 106 107 |
# File 'lib/plurimath/asciimath/constants.rb', line 105 def parens_symbols Utility.parens_hash(:asciimath).keys.delete_if { |sym| SKIP_INPUT_PARENS.include?(sym) } end |
.precompile_constants ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/plurimath/asciimath/constants.rb', line 88 def precompile_constants @values ||= named_hash(UNARY_CLASSES, :unary_class) .merge(named_hash(symbols_array, :symbol)) .merge(named_hash(FONT_STYLES, :fonts)) .merge(named_hash(SPECIAL_BOLD_ALPHABETS, :special_fonts)) @values.sort_by { |v, _| -v.length }.to_h end |
.symbols_array ⇒ Object
101 102 103 |
# File 'lib/plurimath/asciimath/constants.rb', line 101 def symbols_array @@symbols ||= Utility.symbols_hash(:asciimath).keys.concat(parens_symbols) end |