Class: Unitsml::Prefix
Instance Attribute Summary collapse
Instance Method Summary
collapse
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(prefix_name, only_instance = false) ⇒ Prefix
Returns a new instance of Prefix.
9
10
11
12
|
# File 'lib/unitsml/prefix.rb', line 9
def initialize(prefix_name, only_instance = false)
@prefix_name = prefix_name
@only_instance = only_instance
end
|
Instance Attribute Details
#only_instance ⇒ Object
Returns the value of attribute only_instance.
7
8
9
|
# File 'lib/unitsml/prefix.rb', line 7
def only_instance
@only_instance
end
|
#prefix_name ⇒ Object
Returns the value of attribute prefix_name.
7
8
9
|
# File 'lib/unitsml/prefix.rb', line 7
def prefix_name
@prefix_name
end
|
Instance Method Details
#==(other) ⇒ Object
14
15
16
17
18
|
# File 'lib/unitsml/prefix.rb', line 14
def ==(other)
self.class == other.class &&
prefix_name == other&.prefix_name &&
only_instance == other&.only_instance
end
|
#base ⇒ Object
69
70
71
|
# File 'lib/unitsml/prefix.rb', line 69
def base
prefix_instance.base
end
|
#id ⇒ Object
24
25
26
27
28
|
# File 'lib/unitsml/prefix.rb', line 24
def id
@id ||= prefix_instance.identifiers.find do |prefix|
prefix.type == "nist"
end&.id
end
|
#name ⇒ Object
30
31
32
|
# File 'lib/unitsml/prefix.rb', line 30
def name
@name ||= prefix_instance.names.find { |name| name.lang == "en" }.value
end
|
#power ⇒ Object
73
74
75
|
# File 'lib/unitsml/prefix.rb', line 73
def power
prefix_instance.power
end
|
#prefix_instance ⇒ Object
20
21
22
|
# File 'lib/unitsml/prefix.rb', line 20
def prefix_instance
@prefix_instance ||= Unitsdb.prefixes.find_by_symbol_name(prefix_name)
end
|
#prefix_symbols ⇒ Object
34
35
36
|
# File 'lib/unitsml/prefix.rb', line 34
def prefix_symbols
prefix_instance.symbols.last
end
|
#symbolid ⇒ Object
65
66
67
|
# File 'lib/unitsml/prefix.rb', line 65
def symbolid
prefix_symbols&.ascii
end
|
#to_asciimath(_) ⇒ Object
53
54
55
|
# File 'lib/unitsml/prefix.rb', line 53
def to_asciimath(_)
prefix_symbols.ascii
end
|
#to_html(_) ⇒ Object
57
58
59
|
# File 'lib/unitsml/prefix.rb', line 57
def to_html(_)
prefix_symbols.html
end
|
#to_latex(_) ⇒ Object
49
50
51
|
# File 'lib/unitsml/prefix.rb', line 49
def to_latex(_)
prefix_symbols.latex
end
|
#to_unicode(_) ⇒ Object
61
62
63
|
# File 'lib/unitsml/prefix.rb', line 61
def to_unicode(_)
prefix_symbols.unicode
end
|