Class: ODF::Cell
Instance Method Summary collapse
- #contains_url? ⇒ Boolean
-
#initialize(*args) ⇒ Cell
constructor
A new instance of Cell.
- #style=(style_name) ⇒ Object
- #xml ⇒ Object
Methods inherited from Container
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
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 |
#xml ⇒ Object
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 |