Class: Unitsml::Prefix
- Inherits:
-
Object
- Object
- Unitsml::Prefix
- Defined in:
- lib/unitsml/prefix.rb
Instance Attribute Summary collapse
-
#only_instance ⇒ Object
Returns the value of attribute only_instance.
-
#prefix_name ⇒ Object
Returns the value of attribute prefix_name.
Instance Method Summary collapse
- #==(object) ⇒ Object
- #base ⇒ Object
- #fields ⇒ Object
- #id ⇒ Object
-
#initialize(prefix_name, only_instance = false) ⇒ Prefix
constructor
A new instance of Prefix.
- #name ⇒ Object
- #power ⇒ Object
- #prefixes_symbols ⇒ Object
- #symbolid ⇒ Object
- #to_asciimath ⇒ Object
- #to_html ⇒ Object
- #to_latex ⇒ Object
- #to_mathml ⇒ Object
- #to_unicode ⇒ Object
Constructor Details
#initialize(prefix_name, only_instance = false) ⇒ Prefix
Returns a new instance of Prefix.
7 8 9 10 |
# File 'lib/unitsml/prefix.rb', line 7 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.
5 6 7 |
# File 'lib/unitsml/prefix.rb', line 5 def only_instance @only_instance end |
#prefix_name ⇒ Object
Returns the value of attribute prefix_name.
5 6 7 |
# File 'lib/unitsml/prefix.rb', line 5 def prefix_name @prefix_name end |
Instance Method Details
#==(object) ⇒ Object
12 13 14 15 16 |
# File 'lib/unitsml/prefix.rb', line 12 def ==(object) self.class == object.class && prefix_name == object&.prefix_name && only_instance == object&.only_instance end |
#base ⇒ Object
65 66 67 |
# File 'lib/unitsml/prefix.rb', line 65 def base fields&.dig("base") end |
#fields ⇒ Object
26 27 28 |
# File 'lib/unitsml/prefix.rb', line 26 def fields Unitsdb.prefixes_hash.dig(prefix_name, :fields) end |
#id ⇒ Object
18 19 20 |
# File 'lib/unitsml/prefix.rb', line 18 def id Unitsdb.prefixes_hash.dig(prefix_name, :id) end |
#name ⇒ Object
22 23 24 |
# File 'lib/unitsml/prefix.rb', line 22 def name fields.dig("name") end |
#power ⇒ Object
69 70 71 |
# File 'lib/unitsml/prefix.rb', line 69 def power fields&.dig("power") end |
#prefixes_symbols ⇒ Object
30 31 32 |
# File 'lib/unitsml/prefix.rb', line 30 def prefixes_symbols fields&.dig("symbol") end |
#symbolid ⇒ Object
61 62 63 |
# File 'lib/unitsml/prefix.rb', line 61 def symbolid prefixes_symbols["ascii"] if prefixes_symbols end |
#to_asciimath ⇒ Object
49 50 51 |
# File 'lib/unitsml/prefix.rb', line 49 def to_asciimath prefixes_symbols["ascii"] end |
#to_html ⇒ Object
53 54 55 |
# File 'lib/unitsml/prefix.rb', line 53 def to_html prefixes_symbols["html"] end |
#to_latex ⇒ Object
45 46 47 |
# File 'lib/unitsml/prefix.rb', line 45 def to_latex prefixes_symbols["latex"] end |
#to_mathml ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/unitsml/prefix.rb', line 34 def to_mathml symbol = Utility.string_to_html_entity( Utility.html_entity_to_unicode( prefixes_symbols["html"] ), ) return symbol unless only_instance Utility.ox_element("mi") << symbol end |
#to_unicode ⇒ Object
57 58 59 |
# File 'lib/unitsml/prefix.rb', line 57 def to_unicode prefixes_symbols["unicode"] end |