Class: Unitsml::Fenced

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(open_paren, value, close_paren) ⇒ Fenced

Returns a new instance of Fenced.



5
6
7
8
9
# File 'lib/unitsml/fenced.rb', line 5

def initialize(open_paren, value, close_paren)
  @open_paren = open_paren
  @value = value
  @close_paren = close_paren
end

Instance Attribute Details

#close_parenObject (readonly)

Returns the value of attribute close_paren.



3
4
5
# File 'lib/unitsml/fenced.rb', line 3

def close_paren
  @close_paren
end

#open_parenObject (readonly)

Returns the value of attribute open_paren.



3
4
5
# File 'lib/unitsml/fenced.rb', line 3

def open_paren
  @open_paren
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/unitsml/fenced.rb', line 3

def value
  @value
end

Instance Method Details

#==(object) ⇒ Object



11
12
13
14
15
16
# File 'lib/unitsml/fenced.rb', line 11

def ==(object)
  self.class == object.class &&
    open_paren == object&.open_paren &&
    value == object&.value &&
    close_paren == object&.close_paren
end

#dimensions_extractionObject



47
48
49
50
51
52
53
54
# File 'lib/unitsml/fenced.rb', line 47

def dimensions_extraction
  case value
  when Dimension
    value
  when Formula, Fenced
    value.dimensions_extraction
  end
end

#to_asciimath(options = {}) ⇒ Object



18
19
20
# File 'lib/unitsml/fenced.rb', line 18

def to_asciimath(options = {})
  fenced_conversion_for(lang: :asciimath, options: options)
end

#to_html(options = {}) ⇒ Object



39
40
41
# File 'lib/unitsml/fenced.rb', line 39

def to_html(options = {})
  fenced_conversion_for(lang: :html, options: options)
end

#to_latex(options = {}) ⇒ Object



22
23
24
# File 'lib/unitsml/fenced.rb', line 22

def to_latex(options = {})
  fenced_conversion_for(lang: :latex, options: options)
end

#to_mathml(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/unitsml/fenced.rb', line 26

def to_mathml(options = {})
  mathml = value.to_mathml(options)
  return mathml unless options[:explicit_parenthesis]

  fenced = ::Mml::Mrow.new(mo_value: [::Mml::Mo.new(value: open_paren)])
  fenced.ordered = true
  fenced.element_order ||= [xml_order_element("mo")]
  [mathml].flatten.each { |record| add_math_element(fenced, record) }
  fenced.mo_value << ::Mml::Mo.new(value: close_paren)
  fenced.element_order << xml_order_element("mo")
  { method_name: :mrow, value: fenced }
end

#to_unicode(options = {}) ⇒ Object



43
44
45
# File 'lib/unitsml/fenced.rb', line 43

def to_unicode(options = {})
  fenced_conversion_for(lang: :unicode, options: options)
end