Module: Plurimath::UnicodeMath::ParsingRules::ConstantsRules

Includes:
Helper
Included in:
Plurimath::UnicodeMath::Parse
Defined in:
lib/plurimath/unicode_math/parsing_rules/constants_rules.rb

Instance Method Summary collapse

Methods included from Helper

included

Instance Method Details

#arr_to_expression(arr, name = nil) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/plurimath/unicode_math/parsing_rules/constants_rules.rb', line 89

def arr_to_expression(arr, name = nil)
  type = arr.first.class
  if arr.length > 1
    arr.reduce do |expression, expr_string|
      expression = str(expression).as(name) if expression.is_a?(type)
      expression | str(expr_string).as(name)
    end
  else
    str(arr.first).as(name)
  end
end