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.
9
10
11
12
13
|
# 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
Utility.validate_left_right([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
15
16
17
18
|
# File 'lib/plurimath/math/function/unary_function.rb', line 15
def ==(object)
object.class == self.class &&
object.parameter_one == parameter_one
end
|
#class_name ⇒ Object
72
73
74
|
# File 'lib/plurimath/math/function/unary_function.rb', line 72
def class_name
self.class.name.split("::").last.downcase
end
|
#to_asciimath ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/plurimath/math/function/unary_function.rb', line 20
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
42
43
44
45
46
47
48
49
|
# File 'lib/plurimath/math/function/unary_function.rb', line 42
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
37
38
39
40
|
# File 'lib/plurimath/math/function/unary_function.rb', line 37
def to_latex
first_value = "{#{latex_value}}" if parameter_one
"\\#{class_name}#{first_value}"
end
|
#to_mathml_without_math_tag ⇒ Object
#to_omml_without_math_tag ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/plurimath/math/function/unary_function.rb', line 51
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
|