Class: Latex::Table
- Inherits:
-
Object
- Object
- Latex::Table
- Defined in:
- lib/ruby-latex.rb
Instance Attribute Summary collapse
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#label ⇒ Object
Returns the value of attribute label.
Instance Method Summary collapse
- #add_tabular(tabular) ⇒ Object
- #auto_resize ⇒ Object
-
#initialize(caption = nil, label = nil) ⇒ Table
constructor
A new instance of Table.
- #tabular=(tabular) ⇒ Object
- #to_tex ⇒ Object
Constructor Details
#initialize(caption = nil, label = nil) ⇒ Table
Returns a new instance of Table.
8 9 10 11 12 |
# File 'lib/ruby-latex.rb', line 8 def initialize(caption = nil, label = nil) @caption = caption @label = label @tabulars = [] end |
Instance Attribute Details
#caption ⇒ Object
Returns the value of attribute caption.
5 6 7 |
# File 'lib/ruby-latex.rb', line 5 def caption @caption end |
#label ⇒ Object
Returns the value of attribute label.
6 7 8 |
# File 'lib/ruby-latex.rb', line 6 def label @label end |
Instance Method Details
#add_tabular(tabular) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/ruby-latex.rb', line 20 def add_tabular(tabular) raise TypeError, "No implicit conversion from #{tabular.class} to Latex::Tabular" unless tabular.is_a?(Tabular) @tabulars << tabular return self end |
#auto_resize ⇒ Object
14 15 16 17 18 |
# File 'lib/ruby-latex.rb', line 14 def auto_resize @resize = true return self end |
#tabular=(tabular) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/ruby-latex.rb', line 28 def tabular=(tabular) @tabulars.clear add_tabular(tabular) return nil end |
#to_tex ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ruby-latex.rb', line 35 def to_tex out = [] out << "\\begin{table}" out << self.caption_string @tabulars.each do |tabular| out << tabular.to_tex end out << "\\end{table}" return out.join("\n") end |