Class: Rulex::Tex::Reader
Instance Method Summary collapse
-
#initialize ⇒ Reader
constructor
A new instance of Reader.
-
#read(str) ⇒ Array
Takes a string of LaTeX contents, parses it to a Rulex tree, and sets that tree as the Reader’s content.
-
#to_a ⇒ Array
(also: #export)
Exports the Reader’s content.
Constructor Details
#initialize ⇒ Reader
Returns a new instance of Reader.
13 14 15 16 |
# File 'lib/rulex/tex/reader.rb', line 13 def initialize @parser = LatexParser.new @content = [] end |
Instance Method Details
#read(str) ⇒ Array
Takes a string of LaTeX contents, parses it to a Rulex tree, and sets that tree as the Reader’s content
29 30 31 32 33 |
# File 'lib/rulex/tex/reader.rb', line 29 def read str new_content = @parser.parse(str).to_a raise TypeError, "content should be an Array" unless new_content and Array === new_content @content = new_content end |
#to_a ⇒ Array Also known as: export
Exports the Reader’s content
20 21 22 |
# File 'lib/rulex/tex/reader.rb', line 20 def to_a @content end |