Class: Unitsml::Fenced
- Inherits:
-
Object
- Object
- Unitsml::Fenced
- Defined in:
- lib/unitsml/fenced.rb
Instance Attribute Summary collapse
-
#close_paren ⇒ Object
readonly
Returns the value of attribute close_paren.
-
#open_paren ⇒ Object
readonly
Returns the value of attribute open_paren.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(object) ⇒ Object
- #dimensions_extraction ⇒ Object
-
#initialize(open_paren, value, close_paren) ⇒ Fenced
constructor
A new instance of Fenced.
- #to_asciimath(options = {}) ⇒ Object
- #to_html(options = {}) ⇒ Object
- #to_latex(options = {}) ⇒ Object
- #to_mathml(options = {}) ⇒ Object
- #to_unicode(options = {}) ⇒ Object
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_paren ⇒ Object (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_paren ⇒ Object (readonly)
Returns the value of attribute open_paren.
3 4 5 |
# File 'lib/unitsml/fenced.rb', line 3 def open_paren @open_paren end |
#value ⇒ Object (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_extraction ⇒ Object
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( = {}) fenced_conversion_for(lang: :asciimath, options: ) end |
#to_html(options = {}) ⇒ Object
39 40 41 |
# File 'lib/unitsml/fenced.rb', line 39 def to_html( = {}) fenced_conversion_for(lang: :html, options: ) end |
#to_latex(options = {}) ⇒ Object
22 23 24 |
# File 'lib/unitsml/fenced.rb', line 22 def to_latex( = {}) fenced_conversion_for(lang: :latex, 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( = {}) mathml = value.to_mathml() return mathml unless [: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( = {}) fenced_conversion_for(lang: :unicode, options: ) end |