Class: Unitsml::Extender

Inherits:
Object
  • Object
show all
Includes:
MathmlHelper
Defined in:
lib/unitsml/extender.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MathmlHelper

coerce_mml_v4_collection_attributes!, coerce_mml_v4_collection_value, mml_v4_class_for, mml_v4_content_attribute, mml_v4_context, mml_v4_from_xml, mml_v4_new, mml_v4_with_content

Constructor Details

#initialize(symbol) ⇒ Extender

Returns a new instance of Extender.



9
10
11
# File 'lib/unitsml/extender.rb', line 9

def initialize(symbol)
  @symbol = symbol
end

Instance Attribute Details

#symbolObject

Returns the value of attribute symbol.



7
8
9
# File 'lib/unitsml/extender.rb', line 7

def symbol
  @symbol
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
16
# File 'lib/unitsml/extender.rb', line 13

def ==(other)
  self.class == other.class &&
    symbol == other&.symbol
end

#to_asciimath(options) ⇒ Object



31
32
33
# File 'lib/unitsml/extender.rb', line 31

def to_asciimath(options)
  multiplier(options[:multiplier] || symbol)
end

#to_html(options) ⇒ Object



35
36
37
# File 'lib/unitsml/extender.rb', line 35

def to_html(options)
  multiplier(options[:multiplier] || "", unicode: true, html: true)
end

#to_latex(options) ⇒ Object



27
28
29
# File 'lib/unitsml/extender.rb', line 27

def to_latex(options)
  multiplier(options[:multiplier] || "/")
end

#to_mathml(options) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/unitsml/extender.rb', line 18

def to_mathml(options)
  rspace = "thickmathspace" if options[:multiplier] == :space
  extender = multiplier(options[:multiplier] || "", unicode: true)
  {
    method_name: :mo,
    value: mml_v4_new(:mo, value: extender, rspace: rspace),
  }
end

#to_unicode(options) ⇒ Object



39
40
41
42
# File 'lib/unitsml/extender.rb', line 39

def to_unicode(options)
  extender = options[:multiplier] || unicode_extender
  multiplier(extender)
end