Class: Unitsml::Prefix

Inherits:
Object
  • Object
show all
Defined in:
lib/unitsml/prefix.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix_name) ⇒ Prefix

Returns a new instance of Prefix.



7
8
9
# File 'lib/unitsml/prefix.rb', line 7

def initialize(prefix_name)
  @prefix_name = prefix_name
end

Instance Attribute Details

#prefix_nameObject

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



11
12
13
14
# File 'lib/unitsml/prefix.rb', line 11

def ==(object)
  self.class == object.class &&
    prefix_name == object&.prefix_name
end

#baseObject



56
57
58
# File 'lib/unitsml/prefix.rb', line 56

def base
  fields&.dig("base")
end

#fieldsObject



24
25
26
# File 'lib/unitsml/prefix.rb', line 24

def fields
  Unitsdb.prefixes_hash.dig(prefix_name, :fields)
end

#idObject



16
17
18
# File 'lib/unitsml/prefix.rb', line 16

def id
  Unitsdb.prefixes_hash.dig(prefix_name, :id)
end

#nameObject



20
21
22
# File 'lib/unitsml/prefix.rb', line 20

def name
  fields.dig("name")
end

#powerObject



60
61
62
# File 'lib/unitsml/prefix.rb', line 60

def power
  fields&.dig("power")
end

#prefixes_symbolsObject



28
29
30
# File 'lib/unitsml/prefix.rb', line 28

def prefixes_symbols
  fields&.dig("symbol")
end

#symbolidObject



52
53
54
# File 'lib/unitsml/prefix.rb', line 52

def symbolid
  prefixes_symbols["ascii"] if prefixes_symbols
end

#to_asciimathObject



40
41
42
# File 'lib/unitsml/prefix.rb', line 40

def to_asciimath
  prefixes_symbols["ascii"]
end

#to_htmlObject



44
45
46
# File 'lib/unitsml/prefix.rb', line 44

def to_html
  prefixes_symbols["html"]
end

#to_latexObject



36
37
38
# File 'lib/unitsml/prefix.rb', line 36

def to_latex
  prefixes_symbols["latex"]
end

#to_mathmlObject



32
33
34
# File 'lib/unitsml/prefix.rb', line 32

def to_mathml
  prefixes_symbols["html"]
end

#to_unicodeObject



48
49
50
# File 'lib/unitsml/prefix.rb', line 48

def to_unicode
  prefixes_symbols["unicode"]
end