Class: Odf::Element::TableCell

Inherits:
Abstract
  • Object
show all
Defined in:
lib/odf/element/table_cell.rb

Constant Summary collapse

TYPE_MAP =
{
  Fixnum => 'float',
  Float  => 'float',
  String => 'string'
}
VALID_OPTIONS =
{}
XML_TAG =
'table:table-cell'.freeze

Instance Attribute Summary

Attributes inherited from Abstract

#parent, #root

Class Method Summary collapse

Methods inherited from Abstract

#document, #initialize, #valid_options, #xml_tag

Constructor Details

This class inherits a constructor from Odf::Element::Abstract

Class Method Details

.build(parent, content, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/odf/element/table_cell.rb', line 13

def self.build(parent, content, options = {})
  type      = options[:type] || infer_type(content)
  self_opts = {
      'office:value-type' => type,
      'office:value' => content
    }.merge(options)
  this = new(parent, self_opts)

  Odf::Element::Paragraph.build(this, content, options)
  this
end

.infer_type(content) ⇒ Object



25
26
27
# File 'lib/odf/element/table_cell.rb', line 25

def self.infer_type(content)
  TYPE_MAP[content.class] || 'string'
end