class Osheet::Cell

Public Class Methods

new(data_value=nil) click to toggle source
# File lib/osheet/cell.rb, line 12
def initialize(data_value=nil)
  @data    = cast_data_value(data_value)
  @format  = Format.new(:general)
  @rowspan = 1
  @colspan = 1
  @index   = nil
  @href    = nil
  @formula = nil
end

Public Instance Methods

colspan(value=nil) click to toggle source
# File lib/osheet/cell.rb, line 34
def colspan(value=nil)
  value.nil? ? @colspan : @colspan = value
end
data(value=nil) click to toggle source
# File lib/osheet/cell.rb, line 22
def data(value=nil)
  value.nil? ? @data : @data = cast_data_value(value)
end
format(value=nil, opts={}) click to toggle source
# File lib/osheet/cell.rb, line 26
def format(value=nil, opts={})
  value.nil? ? @format : @format = Format.new(value, opts)
end
formula(value=nil) click to toggle source
# File lib/osheet/cell.rb, line 46
def formula(value=nil)
  value.nil? ? @formula : @formula = value
end
href(value=nil) click to toggle source
# File lib/osheet/cell.rb, line 42
def href(value=nil)
  value.nil? ? @href : @href = value
end
index(value=nil) click to toggle source
# File lib/osheet/cell.rb, line 38
def index(value=nil)
  value.nil? ? @index : @index = value
end
rowspan(value=nil) click to toggle source
# File lib/osheet/cell.rb, line 30
def rowspan(value=nil)
  value.nil? ? @rowspan : @rowspan = value
end

Private Instance Methods

cast_data_value(value) click to toggle source
# File lib/osheet/cell.rb, line 52
def cast_data_value(value)
  case value
  when ::String, ::Numeric, ::Date, ::Time, ::DateTime, ::NilClass
    value
  when ::Symbol
    value.to_s
  else
    value.inspect.to_s
  end
end