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

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

Direct Known Subclasses

Boolean, DateTime, Empty, Number, String

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::DefaultAttrReader

attr_reader_with_default

Constructor Details

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

Returns a new instance of Base.



41
42
43
44
45
46
47
48
# File 'lib/roo/excelx/cell/base.rb', line 41

def initialize(value, formula, excelx_type, style, link, coordinate)
  @cell_value = value
  @cell_type = excelx_type if excelx_type
  @formula = formula if formula
  @style = style unless style == 1
  @coordinate = coordinate
  @value = link ? Roo::Link.new(link, value) : value
end

Instance Attribute Details

#cell_typeObject (readonly)

Returns the value of attribute cell_type.



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

def cell_type
  @cell_type
end

#cell_valueObject (readonly)

Returns the value of attribute cell_value.



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

def cell_value
  @cell_value
end

#valueObject Also known as: formatted_value

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#empty?Boolean

Returns:



98
99
100
# File 'lib/roo/excelx/cell/base.rb', line 98

def empty?
  false
end

#excelx_typeObject

DEPRECATED: Please use cell_type instead.



93
94
95
96
# File 'lib/roo/excelx/cell/base.rb', line 93

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.



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

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

#formula?Boolean

Returns:



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

def formula?
  !!(defined?(@formula) && @formula)
end

DEPRECATED: Please use link? instead.



75
76
77
78
# File 'lib/roo/excelx/cell/base.rb', line 75

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

DEPRECATED: Please use link? instead.



81
82
83
84
# File 'lib/roo/excelx/cell/base.rb', line 81

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

#link?Boolean

Returns:



64
65
66
# File 'lib/roo/excelx/cell/base.rb', line 64

def link?
  Roo::Link === @value
end

#presenceObject



102
103
104
# File 'lib/roo/excelx/cell/base.rb', line 102

def presence
  empty? ? nil : self
end

#to_sObject



70
71
72
# File 'lib/roo/excelx/cell/base.rb', line 70

def to_s
  formatted_value
end

#typeObject



50
51
52
53
54
55
56
57
58
# File 'lib/roo/excelx/cell/base.rb', line 50

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