Class: Xmlss::Element::Cell

Inherits:
Object
  • Object
show all
Includes:
Enumeration
Defined in:
lib/xmlss/element/cell.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Cell

Returns a new instance of Cell.



23
24
25
26
27
28
29
30
31
# File 'lib/xmlss/element/cell.rb', line 23

def initialize(*args)
  attrs = args.last.kind_of?(::Hash) ? args.pop : {}

  self.data = [args.last, attrs.delete(:data), ''].reject{|v| v.nil?}.first
  self.merge_across = attrs.delete(:merge_across) || 0
  self.merge_down = attrs.delete(:merge_down) || 0

  attrs.keys.each { |k| self.send("#{k}=", attrs[k]) }
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



12
13
14
# File 'lib/xmlss/element/cell.rb', line 12

def data
  @data
end

#formulaObject

Returns the value of attribute formula.



10
11
12
# File 'lib/xmlss/element/cell.rb', line 10

def formula
  @formula
end

#hrefObject

Returns the value of attribute href.



10
11
12
# File 'lib/xmlss/element/cell.rb', line 10

def href
  @href
end

#indexObject

Returns the value of attribute index.



10
11
12
# File 'lib/xmlss/element/cell.rb', line 10

def index
  @index
end

#merge_acrossObject

Returns the value of attribute merge_across.



10
11
12
# File 'lib/xmlss/element/cell.rb', line 10

def merge_across
  @merge_across
end

#merge_downObject

Returns the value of attribute merge_down.



10
11
12
# File 'lib/xmlss/element/cell.rb', line 10

def merge_down
  @merge_down
end

#style_idObject

Returns the value of attribute style_id.



10
11
12
# File 'lib/xmlss/element/cell.rb', line 10

def style_id
  @style_id
end

Class Method Details

.writerObject



8
# File 'lib/xmlss/element/cell.rb', line 8

def self.writer; :cell; end

Instance Method Details

#data_xml_valueObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/xmlss/element/cell.rb', line 38

def data_xml_value
  case self.data
  when ::Date, ::Time, ::DateTime
    self.data.strftime("%Y-%m-%dT%H:%M:%S")
  when ::TrueClass
    1
  when ::FalseClass
    0
  else
    self.data.to_s
  end
end