Class: Damsi::Ticks
- Inherits:
-
Object
- Object
- Damsi::Ticks
- Defined in:
- lib/damsi/ticks.rb
Overview
Ticks accumulated after the evaluation of a DFG.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2023 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
-
#initialize ⇒ Ticks
constructor
A new instance of Ticks.
-
#push(tick, tex) ⇒ Object
Add a message in properly formatted LaTeX.
- #to_latex(log) ⇒ Object
Constructor Details
#initialize ⇒ Ticks
Returns a new instance of Ticks.
26 27 28 |
# File 'lib/damsi/ticks.rb', line 26 def initialize @ticks = {} end |
Instance Method Details
#push(tick, tex) ⇒ Object
Add a message in properly formatted LaTeX. If the TeX syntax is broken, there will be a runtime problem later.
32 33 34 35 |
# File 'lib/damsi/ticks.rb', line 32 def push(tick, tex) @ticks[tick] = [] if @ticks[tick].nil? @ticks[tick].push(tex) end |
#to_latex(log) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/damsi/ticks.rb', line 37 def to_latex(log) total = @ticks.count if total.zero? log.info('no ticks') return end log.debug("This tabular is auto-generated by damsi, at #{Time.now}") log.info("\\begin{tabular}{#{'l' * total}}") pos = 0 @ticks.each do |_n, t| log.info(" #{'\\hspace*{1em} & ' * pos} \\multicolumn{#{total - pos}}{l}{\\begin{tabular}{|l}") t.each do |e| log.info(" #{e} \\\\") end log.info(' \\end{tabular}} \\\\') pos += 1 end log.info('\\end{tabular}') end |