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
- #arr_to_expression(arr, name = nil) ⇒ Object
- #hash_values(expr_hash, name) ⇒ Object
- #unicoded_fonts_to_expression(hash, name = nil) ⇒ Object
Methods included from Helper
Instance Method Details
#arr_to_expression(arr, name = nil) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/plurimath/unicode_math/parsing_rules/constants_rules.rb', line 90 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 |
#hash_values(expr_hash, name) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/plurimath/unicode_math/parsing_rules/constants_rules.rb', line 112 def hash_values(expr_hash, name) if expr_hash.keys.length > 1 type = expr_hash.first.class expr_hash.reduce do |expression, (_, hex_code)| expression = str(name).absent?.as(name).as(:unicoded_font_class) >> str(expression.last).as(:symbol) if expression.is_a?(type) expression | str(name).absent?.as(name).as(:unicoded_font_class) >> str(hex_code).as(:symbol) end else str(expr_hash.values.last) end end |
#unicoded_fonts_to_expression(hash, name = nil) ⇒ Object
102 103 104 105 106 107 108 109 110 |
# File 'lib/plurimath/unicode_math/parsing_rules/constants_rules.rb', line 102 def unicoded_fonts_to_expression(hash, name = nil) type = hash.first.class hash.reduce do |expression, expr_hash| if expression.is_a?(type) expression = hash_values(expression.last, expression.first) end expression | hash_values(expr_hash.last, expr_hash.first) end end |