Class: Rulex::Tex::Writer
- Inherits:
-
Object
- Object
- Rulex::Tex::Writer
- Defined in:
- lib/rulex/tex/writer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #import(arr) ⇒ Object
-
#initialize ⇒ Writer
constructor
A new instance of Writer.
- #to_s ⇒ Object (also: #export)
Constructor Details
#initialize ⇒ Writer
Returns a new instance of Writer.
5 6 7 |
# File 'lib/rulex/tex/writer.rb', line 5 def initialize @content = '' end |
Class Method Details
.to_str(item) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rulex/tex/writer.rb', line 9 def self.to_str item case item[:type] when :command str = "\\#{item[:name]}" if opts = item[:options] str += '[' + opts.join(',') + ']' end item[:arguments].each do |arg| str += "{#{arg}}" end str += "\n" when :text res = item[:text] when :environment str = "\\begin{#{item[:name]}}\n" if children = item[:children] str += item[:children].inject(""){|acc, c| acc += Rulex::Tex::Writer.to_str c} end res = str += "\\end{#{item[:name]}}\n" else str = "" res = str += item[:children].inject(""){|acc, c| acc += Rulex::Tex::Writer.to_str c} if item[:children] end end |