Class: Unitsml::Extender
- Inherits:
-
Object
- Object
- Unitsml::Extender
- Defined in:
- lib/unitsml/extender.rb
Instance Attribute Summary collapse
-
#symbol ⇒ Object
Returns the value of attribute symbol.
Instance Method Summary collapse
- #==(object) ⇒ Object
-
#initialize(symbol) ⇒ Extender
constructor
A new instance of Extender.
- #to_asciimath(options) ⇒ Object
- #to_html(options) ⇒ Object
- #to_latex(options) ⇒ Object
- #to_mathml(options) ⇒ Object
- #to_unicode(options) ⇒ Object
Constructor Details
#initialize(symbol) ⇒ Extender
Returns a new instance of Extender.
7 8 9 |
# File 'lib/unitsml/extender.rb', line 7 def initialize(symbol) @symbol = symbol end |
Instance Attribute Details
#symbol ⇒ Object
Returns the value of attribute symbol.
5 6 7 |
# File 'lib/unitsml/extender.rb', line 5 def symbol @symbol end |
Instance Method Details
#==(object) ⇒ Object
11 12 13 14 |
# File 'lib/unitsml/extender.rb', line 11 def ==(object) self.class == object.class && symbol == object&.symbol end |
#to_asciimath(options) ⇒ Object
29 30 31 |
# File 'lib/unitsml/extender.rb', line 29 def to_asciimath() multiplier([:multiplier] || symbol) end |
#to_html(options) ⇒ Object
33 34 35 |
# File 'lib/unitsml/extender.rb', line 33 def to_html() multiplier([:multiplier] || "⋅", unicode: true, html: true) end |
#to_latex(options) ⇒ Object
25 26 27 |
# File 'lib/unitsml/extender.rb', line 25 def to_latex() multiplier([:multiplier] || "/") end |
#to_mathml(options) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/unitsml/extender.rb', line 16 def to_mathml() rspace = "thickmathspace" if [:multiplier] == :space extender = multiplier([:multiplier] || "⋅", unicode: true) { method_name: :mo, value: ::Mml::Mo.new(value: extender, rspace: rspace), } end |
#to_unicode(options) ⇒ Object
37 38 39 40 41 |
# File 'lib/unitsml/extender.rb', line 37 def to_unicode() extender = [:multiplier] || symbol == "*" ? "·" : symbol multiplier(extender) end |