Class: RubyRTF::Table::Row::Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-rtf/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row, idx) ⇒ Cell

Returns a new instance of Cell.



46
47
48
49
50
# File 'lib/ruby-rtf/table.rb', line 46

def initialize(row, idx)
  @row = row
  @idx = idx
  @sections = []
end

Instance Attribute Details

#idxObject

Returns the value of attribute idx.



44
45
46
# File 'lib/ruby-rtf/table.rb', line 44

def idx
  @idx
end

#rowObject

Returns the value of attribute row.



44
45
46
# File 'lib/ruby-rtf/table.rb', line 44

def row
  @row
end

#sectionsObject

Returns the value of attribute sections.



44
45
46
# File 'lib/ruby-rtf/table.rb', line 44

def sections
  @sections
end

Instance Method Details

#<<(obj) ⇒ Object



52
53
54
# File 'lib/ruby-rtf/table.rb', line 52

def <<(obj)
  @sections << obj
end

#tableObject



56
57
58
# File 'lib/ruby-rtf/table.rb', line 56

def table
  row.table
end

#widthObject



60
61
62
63
64
65
66
67
68
# File 'lib/ruby-rtf/table.rb', line 60

def width
  gap = row.table.half_gap
  left_margin = row.table.left_margin

  end_pos = row.end_positions[idx]
  prev_pos = idx == 0 ? 0 : row.end_positions[idx - 1]

  ((end_pos - prev_pos - (2 * gap) - left_margin) / row.end_positions[-1]) * 100
end