Class: Spreadsheet::ParseExcel::Worksheet::Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/parseexcel/parseexcel.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Cell) initialize(value, format, row, idx)

A new instance of Cell



24
25
26
27
28
29
30
# File 'lib/parseexcel/parseexcel.rb', line 24

def initialize value, format, row, idx
  @format = format
  @idx = idx
  @row = row
  @value = value
  @encoding = Spreadsheet.client_encoding
end

Instance Attribute Details

- (Object) annotation

Returns the value of attribute annotation



22
23
24
# File 'lib/parseexcel/parseexcel.rb', line 22

def annotation
  @annotation
end

- (Object) book

Returns the value of attribute book



22
23
24
# File 'lib/parseexcel/parseexcel.rb', line 22

def book
  @book
end

- (Object) code

Returns the value of attribute code



22
23
24
# File 'lib/parseexcel/parseexcel.rb', line 22

def code
  @code
end

- (Object) encoding

Returns the value of attribute encoding



22
23
24
# File 'lib/parseexcel/parseexcel.rb', line 22

def encoding
  @encoding
end

- (Object) format

Returns the value of attribute format



22
23
24
# File 'lib/parseexcel/parseexcel.rb', line 22

def format
  @format
end

- (Object) kind

Returns the value of attribute kind



22
23
24
# File 'lib/parseexcel/parseexcel.rb', line 22

def kind
  @kind
end

- (Object) numeric

Returns the value of attribute numeric



22
23
24
# File 'lib/parseexcel/parseexcel.rb', line 22

def numeric
  @numeric
end

- (Object) rich

Returns the value of attribute rich



22
23
24
# File 'lib/parseexcel/parseexcel.rb', line 22

def rich
  @rich
end

- (Object) value

Returns the value of attribute value



22
23
24
# File 'lib/parseexcel/parseexcel.rb', line 22

def value
  @value
end

Instance Method Details

- (Object) date



31
32
33
# File 'lib/parseexcel/parseexcel.rb', line 31

def date
  @row.date @idx
end

- (Object) datetime



34
35
36
# File 'lib/parseexcel/parseexcel.rb', line 34

def datetime
  @row.datetime @idx
end

- (Object) to_f



40
41
42
# File 'lib/parseexcel/parseexcel.rb', line 40

def to_f
  @value.to_f
end

- (Object) to_i



37
38
39
# File 'lib/parseexcel/parseexcel.rb', line 37

def to_i
  @value.to_i
end

- (Object) to_s(target_encoding = nil)



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/parseexcel/parseexcel.rb', line 43

def to_s(target_encoding=nil)
  if(target_encoding)
    begin
      Iconv.new(target_encoding, @encoding).iconv(@value)
    rescue
      Iconv.new(target_encoding, 'ascii').iconv(@value.to_s)
    end
  else
    @value.to_s
  end
end

- (Object) type



54
55
56
57
58
59
60
61
62
# File 'lib/parseexcel/parseexcel.rb', line 54

def type
  if @format && (@format.date? || @format.time?)
    :date
  elsif @value.is_a?(Numeric)
    :numeric
  else
    :text
  end
end