Class: Roo::Excelx::Cell::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/roo/excelx/cell/base.rb

Direct Known Subclasses

Boolean, DateTime, Empty, Number, String

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, formula, excelx_type, style, link, coordinate) ⇒ Base

Returns a new instance of Base.



36
37
38
39
40
41
42
43
44
45
# File 'lib/roo/excelx/cell/base.rb', line 36

def initialize(value, formula, excelx_type, style, link, coordinate)
  @link = !!link
  @cell_value = value
  @cell_type = excelx_type
  @formula = formula
  @style = style
  @coordinate = coordinate
  @type = :base
  @value = link? ? Roo::Link.new(link, value) : value
end

Instance Attribute Details

#cell_typeObject (readonly)

Returns the value of attribute cell_type.



5
6
7
# File 'lib/roo/excelx/cell/base.rb', line 5

def cell_type
  @cell_type
end

#cell_valueObject (readonly)

Returns the value of attribute cell_value.



5
6
7
# File 'lib/roo/excelx/cell/base.rb', line 5

def cell_value
  @cell_value
end

#styleObject (readonly)

FIXME: I think style should be deprecated. Having a style attribute

for a cell doesn't really accomplish much. It seems to be used
when you want to export to excelx.


10
11
12
# File 'lib/roo/excelx/cell/base.rb', line 10

def style
  @style
end

#valueObject Also known as: formatted_value

Returns the value of attribute value.



5
6
7
# File 'lib/roo/excelx/cell/base.rb', line 5

def value
  @value
end

Instance Method Details

#empty?Boolean

Returns:



88
89
90
# File 'lib/roo/excelx/cell/base.rb', line 88

def empty?
  false
end

#excelx_typeObject

DEPRECATED: Please use cell_type instead.



83
84
85
86
# File 'lib/roo/excelx/cell/base.rb', line 83

def excelx_type
  warn '[DEPRECATION] `excelx_type` is deprecated.  Please use `cell_type` instead.'
  cell_type
end

#excelx_valueObject

DEPRECATED: Please use cell_value instead.



77
78
79
80
# File 'lib/roo/excelx/cell/base.rb', line 77

def excelx_value
  warn '[DEPRECATION] `excelx_value` is deprecated.  Please use `cell_value` instead.'
  cell_value
end

#formula?Boolean

Returns:



57
58
59
# File 'lib/roo/excelx/cell/base.rb', line 57

def formula?
  !!@formula
end

DEPRECATED: Please use link instead.



72
73
74
# File 'lib/roo/excelx/cell/base.rb', line 72

def hyperlink
  warn '[DEPRECATION] `hyperlink` is deprecated.  Please use `link` instead.'
end

#link?Boolean

Returns:



61
62
63
# File 'lib/roo/excelx/cell/base.rb', line 61

def link?
  !!@link
end

#to_sObject



67
68
69
# File 'lib/roo/excelx/cell/base.rb', line 67

def to_s
  formatted_value
end

#typeObject



47
48
49
50
51
52
53
54
55
# File 'lib/roo/excelx/cell/base.rb', line 47

def type
  if formula?
    :formula
  elsif link?
    :link
  else
    @type
  end
end