Class: Latex::Row
- Inherits:
-
Object
show all
- Defined in:
- lib/ruby-latex.rb
Defined Under Namespace
Classes: WrongRowException
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(hash) ⇒ Row
Returns a new instance of Row.
212
213
214
215
216
|
# File 'lib/ruby-latex.rb', line 212
def initialize(hash)
raise(WrongRowException, "Hash expected") unless hash.is_a?(Hash)
@row = hash
end
|
Instance Attribute Details
#family ⇒ Object
Returns the value of attribute family.
210
211
212
|
# File 'lib/ruby-latex.rb', line 210
def family
@family
end
|
Instance Method Details
#[](col) ⇒ Object
228
229
230
|
# File 'lib/ruby-latex.rb', line 228
def [](col)
@row[col]
end
|
237
238
239
|
# File 'lib/ruby-latex.rb', line 237
def formatted
@family.columns.map { |col| [col, @family.format(row[col], col) ] }.to_h
end
|
#row ⇒ Object
224
225
226
|
# File 'lib/ruby-latex.rb', line 224
def row
@row
end
|
#sizes ⇒ Object
232
233
234
235
|
# File 'lib/ruby-latex.rb', line 232
def sizes
styled = self.styled
@family.columns.map { |col| [col, styled[col].length] }.to_h
end
|
#styled ⇒ Object
241
242
243
|
# File 'lib/ruby-latex.rb', line 241
def styled
self.formatted.map { |col, content| [col, @family.style(content) ] }.to_h
end
|
#to_tex(column_sizes) ⇒ Object
245
246
247
|
# File 'lib/ruby-latex.rb', line 245
def to_tex(column_sizes)
self.styled.map { |col, content| (" " * (column_sizes[col] - content.length)) + content }.join(" & ") + " \\\\"
end
|