Class: Plurimath::Omml::Utility

Inherits:
Utility
  • Object
show all
Extended by:
Mathml::FunctionTokenResolver
Defined in:
lib/plurimath/omml/utility.rb

Overview

Omml-specific helper extracted from Plurimath::Utility (code-quality refactor). Subclasses Utility so bareword Utility.<generic> calls inside Omml files keep resolving here and inherit the generic helpers.

Class Method Summary collapse

Methods included from Mathml::FunctionTokenResolver

contextual_accent_from_token

Class Method Details

.populate_function_classes(mrow = []) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/plurimath/omml/utility.rb', line 33

def populate_function_classes(mrow = [])
  flatten_mrow = mrow.flatten.compact
  unary_function_classes(flatten_mrow)
  binary_function_classes(flatten_mrow)
  ternary_function_classes(flatten_mrow)
  flatten_mrow
end

.resolve_symbol_token(value) ⇒ Object



26
27
28
29
30
31
# File 'lib/plurimath/omml/utility.rb', line 26

def resolve_symbol_token(value)
  return nil if value.nil?

  function_from_token(value) ||
    symbols_class(string_to_html_entity(value.to_s), lang: :omml)
end

.resolve_text_token(value) ⇒ Object



20
21
22
23
24
# File 'lib/plurimath/omml/utility.rb', line 20

def resolve_text_token(value)
  return nil if value.nil?

  function_from_token(value) || text_token(value)
end

.valid_class(object) ⇒ Object



14
15
16
17
18
# File 'lib/plurimath/omml/utility.rb', line 14

def valid_class(object)
  text = object.extract_class_name_from_text
  (object.extractable? && Asciimath::Constants::SUB_SUP_CLASSES.include?(text)) ||
    Latex::Constants::SYMBOLS[text&.to_sym] == :power_base
end