Class: Plurimath::Latex::Transform

Inherits:
Parslet::Transform
  • Object
show all
Defined in:
lib/plurimath/latex/transform.rb

Class Method Summary collapse

Class Method Details

.get_class(text) ⇒ Object



292
293
294
# File 'lib/plurimath/latex/transform.rb', line 292

def get_class(text)
  Object.const_get("Plurimath::Math::Function::#{text.to_s.capitalize}")
end

.organize_table(array, table = [], table_data = [], table_row = []) ⇒ Object



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/plurimath/latex/transform.rb', line 273

def organize_table(array, table = [], table_data = [], table_row = [])
  array.each do |data|
    if data.is_a?(Math::Symbol) && data.value == "&"
      table_row << Math::Function::Td.new(table_data)
      table_data = []
    elsif data.is_a?(Math::Symbol) && data.value == "\\\\"
      table_row << Math::Function::Td.new(table_data)
      table << Math::Function::Tr.new(table_row.flatten)
      table_row  = []
      table_data = []
    else
      table_data << data
    end
  end
  table_row << Math::Function::Td.new(table_data) if table_data
  table << Math::Function::Tr.new(table_row) unless table_row.empty?
  table
end