Class: Roo::Excelx::Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/roo/excelx/cell.rb,
lib/roo/excelx/cell/base.rb,
lib/roo/excelx/cell/date.rb,
lib/roo/excelx/cell/time.rb,
lib/roo/excelx/cell/empty.rb,
lib/roo/excelx/cell/number.rb,
lib/roo/excelx/cell/string.rb,
lib/roo/excelx/cell/boolean.rb,
lib/roo/excelx/cell/datetime.rb

Defined Under Namespace

Classes: Base, Boolean, Coordinate, Date, DateTime, Empty, Number, String, Time

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, type, formula, excelx_type, excelx_value, style, hyperlink, base_date, coordinate) ⇒ Cell

DEPRECATED: Please use Cell.create_cell instead.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/roo/excelx/cell.rb', line 18

def initialize(value, type, formula, excelx_type, excelx_value, style, hyperlink, base_date, coordinate)
  warn '[DEPRECATION] `Cell.new` is deprecated.  Please use `Cell.create_cell` instead.'
  @type = type
  @formula = formula
  @base_date = base_date if [:date, :datetime].include?(@type)
  @excelx_type = excelx_type
  @excelx_value = excelx_value
  @style = style
  @value = type_cast_value(value)
  @value = Roo::Link.new(hyperlink, @value.to_s) if hyperlink
  @coordinate = coordinate
end

Instance Attribute Details

#coordinateObject (readonly)

Returns the value of attribute coordinate.



14
15
16
# File 'lib/roo/excelx/cell.rb', line 14

def coordinate
  @coordinate
end

#excelx_typeObject (readonly)

Returns the value of attribute excelx_type.



14
15
16
# File 'lib/roo/excelx/cell.rb', line 14

def excelx_type
  @excelx_type
end

#excelx_valueObject (readonly)

Returns the value of attribute excelx_value.



14
15
16
# File 'lib/roo/excelx/cell.rb', line 14

def excelx_value
  @excelx_value
end

#formulaObject (readonly)

Returns the value of attribute formula.



14
15
16
# File 'lib/roo/excelx/cell.rb', line 14

def formula
  @formula
end

Returns the value of attribute hyperlink.



14
15
16
# File 'lib/roo/excelx/cell.rb', line 14

def hyperlink
  @hyperlink
end

#styleObject (readonly)

Returns the value of attribute style.



14
15
16
# File 'lib/roo/excelx/cell.rb', line 14

def style
  @style
end

#valueObject

Returns the value of attribute value.



14
15
16
# File 'lib/roo/excelx/cell.rb', line 14

def value
  @value
end

Class Method Details

.cell_class(type) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/roo/excelx/cell.rb', line 46

def self.cell_class(type)
  case type
  when :string
    Cell::String
  when :boolean
    Cell::Boolean
  when :number
    Cell::Number
  when :date
    Cell::Date
  when :datetime
    Cell::DateTime
  when :time
    Cell::Time
  end
end

.create_cell(type, *values) ⇒ Object



42
43
44
# File 'lib/roo/excelx/cell.rb', line 42

def self.create_cell(type, *values)
  cell_class(type)&.new(*values)
end

Instance Method Details

#typeObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/roo/excelx/cell.rb', line 31

def type
  case
  when @formula
    :formula
  when @value.is_a?(Roo::Link)
    :link
  else
    @type
  end
end