Class: ODF::Cell

Inherits:
Container show all
Defined in:
lib/odf/cell.rb

Instance Method Summary collapse

Methods inherited from Container

contains, create

Constructor Details

#initialize(*args) ⇒ Cell

Returns a new instance of Cell.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/odf/cell.rb', line 30

def initialize(*args)
  value = args.first || ''
  opts = args.last.instance_of?(Hash) ? args.last : {}

  @url = opts[:url]
  @type = opts[:type] || :string
  unless value.instance_of?(Hash)
    if value.respond_to? :strftime
      @value = value.strftime("%Y-%m-%d")
    else
      @value = value.to_s.strip
    end
  end

  @elem_attrs = make_element_attributes(@type, @value, opts)
  @mutiply = (opts[:span] || 1).to_i

  make_value_paragraph
end

Instance Method Details

#contains_url?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/odf/cell.rb', line 63

def contains_url?
  !@url.nil? && !@url.empty?
end

#style=(style_name) ⇒ Object



50
51
52
# File 'lib/odf/cell.rb', line 50

def style=(style_name)
  @elem_attrs['table:style-name'] = style_name
end

#xmlObject



54
55
56
57
58
59
60
61
# File 'lib/odf/cell.rb', line 54

def xml
  markup = Builder::XmlMarkup.new
  text = markup.tag! 'table:table-cell', @elem_attrs do |xml|
    xml << paragraphs_xml
  end
  (@mutiply - 1).times {text = markup.tag! 'table:table-cell'}
  text
end