Class: Plurimath::Math::Symbol
  
  
  
  
  
    - Inherits:
 
    - 
      Core
      
        
          - Object
 
          
            - Core
 
          
            - Plurimath::Math::Symbol
 
          
        
        show all
      
     
  
  
  
  
  
  
  
  
  
  
    - Defined in:
 
    - lib/plurimath/math/symbol.rb
 
  
  
 
  Instance Attribute Summary collapse
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods inherited from Core
  #class_name, #empty_tag, #omml_parameter
  Constructor Details
  
    
  
  
    #initialize(sym)  ⇒ Symbol 
  
  
  
  
    
Returns a new instance of Symbol.
   
 
  
  
    
      
8
9
10 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 8
def initialize(sym)
  @value = sym.is_a?(Parslet::Slice) ? sym.to_s : sym
end 
     | 
  
 
  
 
  
    Instance Attribute Details
    
      
      
      
  
  
    #value  ⇒ Object 
  
  
  
  
    
Returns the value of attribute value.
   
 
  
  
    
      
6
7
8 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 6
def value
  @value
end 
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    #==(object)  ⇒ Object 
  
  
  
  
    
      
12
13
14 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 12
def ==(object)
  object.value == value
end 
     | 
  
 
    
      
  
  
    #insert_t_tag  ⇒ Object 
  
  
  
  
    
      
65
66
67
68
69 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 65
def insert_t_tag
  r_tag = Utility.ox_element("r", namespace: "m")
  r_tag << (Utility.ox_element("t", namespace: "m") << value)
  [r_tag]
end
     | 
  
 
    
      
  
  
    #nary_attr_value  ⇒ Object 
  
  
  
  
    
      
75
76
77 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 75
def nary_attr_value
  value
end 
     | 
  
 
    
      
  
  
    #tag_name  ⇒ Object 
  
  
  
  
    
      
71
72
73 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 71
def tag_name
  ["⋀", "⋁", "⋂", "⋃"].include?(value) ? "underover" : "subsup"
end 
     | 
  
 
    
      
  
  
    #to_asciimath  ⇒ Object 
  
  
  
  
    
      
16
17
18
19
20
21
22
23
24
25
26 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 16
def to_asciimath
  return "" if value.nil?
  symbol = Asciimath::Constants::SYMBOLS.invert[value.strip.to_sym]
  unicodes = Latex::Constants::UNICODE_SYMBOLS.invert
  if value.match?(/&#x[0-9\w]+;/) && symbol.nil? && unicodes[value]
    return unicodes[value].to_s
  end
  symbol ? symbol.to_s : value
end
     | 
  
 
    
      
  
  
    #to_html  ⇒ Object 
  
  
  
  
    
      
57
58
59 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 57
def to_html
  value
end 
     | 
  
 
    
      
  
  
    #to_latex  ⇒ Object 
  
  
  
  
    
      
42
43
44
45
46
47
48
49
50
51
52
53
54
55 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 42
def to_latex
  returned = specific_values
  return returned if returned
  special_char = %w[& #]
  symbols = Latex::Constants::UNICODE_SYMBOLS.invert
  symbol = symbols[value]
  if Latex::Constants::SYMBOLS[symbol] == :operant
    special_char.include?(value) ? "\\#{symbol}" : symbol
  else
    symbols.key?(value) ? "\\#{symbol}" : value
  end
end
     | 
  
 
    
      
  
  
    #to_mathml_without_math_tag  ⇒ Object 
  
  
  
  
    
      
28
29
30
31
32
33
34
35
36
37
38
39
40 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 28
def to_mathml_without_math_tag
  mi_tag = Utility.ox_element("mi")
  return mi_tag if ["{:", ":}"].include?(value)
  unicodes = Mathml::Constants::UNICODE_SYMBOLS
  unicode = unicodes.invert[value]
  if operator?(unicode) || unicode || explicit_checks(unicode)
    mo_value = (unicodes[value] || unicode || value).to_s
    return Utility.ox_element("mo") << mo_value
  end
  mi_tag << value
end
     | 
  
 
    
      
  
  
    #to_omml_without_math_tag  ⇒ Object 
  
  
  
  
    
      
61
62
63 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 61
def to_omml_without_math_tag
  value
end 
     | 
  
 
    
      
  
  
    
      
79
80
81 
     | 
    
      # File 'lib/plurimath/math/symbol.rb', line 79
def validate_function_formula
  false
end 
     |