Class: Proforma::Modeling::Table::Cell

Inherits:
Object
  • Object
show all
Includes:
Compiling::Compilable, Proforma::Modeling::Types::Align
Defined in:
lib/proforma/modeling/table/cell.rb

Overview

The lowest unit of a table. Each row is comprised of zero or more cells.

Constant Summary

Constants included from Proforma::Modeling::Types::Align

Proforma::Modeling::Types::Align::CENTER, Proforma::Modeling::Types::Align::LEFT, Proforma::Modeling::Types::Align::RIGHT

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(align: LEFT, text: '', width: nil) ⇒ Cell

Returns a new instance of Cell.



21
22
23
24
25
# File 'lib/proforma/modeling/table/cell.rb', line 21

def initialize(align: LEFT, text: '', width: nil)
  @align  = align
  @text   = text
  @width  = width
end

Instance Attribute Details

#alignObject



27
28
29
# File 'lib/proforma/modeling/table/cell.rb', line 27

def align
  @align || LEFT
end

#textObject



31
32
33
# File 'lib/proforma/modeling/table/cell.rb', line 31

def text
  @text.to_s
end

#widthObject



35
36
37
# File 'lib/proforma/modeling/table/cell.rb', line 35

def width
  @width ? @width.to_f : nil
end

Instance Method Details

#compile(data, evaluator) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/proforma/modeling/table/cell.rb', line 39

def compile(data, evaluator)
  self.class.new(
    align: align,
    text: evaluator.text(data, text),
    width: width
  )
end