Class: Plurimath::Math::Function::UnaryFunction
- Inherits:
-
Object
- Object
- Plurimath::Math::Function::UnaryFunction
show all
- Defined in:
- lib/plurimath/math/function/unary_function.rb
Direct Known Subclasses
Abs, Arccos, Arcsin, Arctan, Bar, Cancel, Ceil, Cos, Cosh, Cot, Coth, Csc, Csch, Ddot, Deg, Det, Dim, Dot, Exp, F, Floor, G, Gcd, Glb, Hat, Hom, Ker, Lcm, Left, Lg, Liminf, Limsup, Ln, Longdiv, Lub, Max, Mbox, Min, Msgroup, Msline, Norm, Obrace, Phantom, Right, Scarries, Scarry, Sec, Sech, Sin, Sinh, Sqrt, Sup, Tan, Tanh, Text, Tilde, Tr, Ubrace, Ul, Underline, Vec
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(parameter_one = nil) ⇒ UnaryFunction
Returns a new instance of UnaryFunction.
[View source]
9
10
11
12
|
# File 'lib/plurimath/math/function/unary_function.rb', line 9
def initialize(parameter_one = nil)
parameter_one = parameter_one.to_s if parameter_one.is_a?(Parslet::Slice)
@parameter_one = parameter_one
end
|
Instance Attribute Details
#parameter_one ⇒ Object
Returns the value of attribute parameter_one.
7
8
9
|
# File 'lib/plurimath/math/function/unary_function.rb', line 7
def parameter_one
@parameter_one
end
|
Instance Method Details
#==(object) ⇒ Object
[View source]
14
15
16
17
|
# File 'lib/plurimath/math/function/unary_function.rb', line 14
def ==(object)
object.class == self.class &&
object.parameter_one == parameter_one
end
|
#class_name ⇒ Object
[View source]
71
72
73
|
# File 'lib/plurimath/math/function/unary_function.rb', line 71
def class_name
self.class.name.split("::").last.downcase
end
|
#to_asciimath ⇒ Object
[View source]
19
20
21
22
23
24
25
26
|
# File 'lib/plurimath/math/function/unary_function.rb', line 19
def to_asciimath
value = if Utility::UNARY_CLASSES.any?(class_name)
asciimath_value
elsif parameter_one
"(#{asciimath_value})"
end
"#{class_name}#{value}"
end
|
#to_html ⇒ Object
[View source]
41
42
43
44
45
46
47
48
|
# File 'lib/plurimath/math/function/unary_function.rb', line 41
def to_html
first_value = if parameter_one.is_a?(Array)
"<i>#{parameter_one.map(&:to_html).join}</i>"
elsif parameter_one
"<i>#{parameter_one.to_html}</i>"
end
"<i>#{class_name}</i>#{first_value}"
end
|
#to_latex ⇒ Object
[View source]
36
37
38
39
|
# File 'lib/plurimath/math/function/unary_function.rb', line 36
def to_latex
first_value = "{#{latex_value}}" if parameter_one
"\\#{class_name}#{first_value}"
end
|
#to_omml_without_math_tag ⇒ Object
[View source]
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/plurimath/math/function/unary_function.rb', line 50
def to_omml_without_math_tag
func = Utility.ox_element("func", namespace: "m")
funcpr = Utility.ox_element("funcPr", namespace: "m")
funcpr << Utility.pr_element("ctrl", true, namespace: "m")
fname = Utility.ox_element("fName", namespace: "m")
mr = Utility.ox_element("r", namespace: "m")
rpr = Utility.rpr_element
mt = Utility.ox_element("t", namespace: "m") << class_name
fname << Utility.update_nodes(mr, [rpr, mt])
me = Utility.ox_element("e", namespace: "m")
Utility.update_nodes(me, omml_value) if parameter_one
Utility.update_nodes(
func,
[
funcpr,
fname,
me,
],
)
end
|