Class: Spreadsheet::Excel::SstEntry

Inherits:
Object
  • Object
show all
Includes:
Spreadsheet::Encodings
Defined in:
lib/spreadsheet/excel/sst_entry.rb

Overview

Shared String Table Entry

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (SstEntry) initialize(opts = {})

A new instance of SstEntry



11
12
13
14
15
16
17
# File 'lib/spreadsheet/excel/sst_entry.rb', line 11

def initialize opts = {}
  @content = nil
  @offset = opts[:offset]
  @ole    = opts[:ole]
  @reader = opts[:reader]
  @continuations = []
end

Instance Attribute Details

- (Object) available

Returns the value of attribute available



9
10
11
# File 'lib/spreadsheet/excel/sst_entry.rb', line 9

def available
  @available
end

- (Object) chars

Returns the value of attribute chars



9
10
11
# File 'lib/spreadsheet/excel/sst_entry.rb', line 9

def chars
  @chars
end

- (Object) continued_chars

Returns the value of attribute continued_chars



9
10
11
# File 'lib/spreadsheet/excel/sst_entry.rb', line 9

def continued_chars
  @continued_chars
end

- (Object) flags

Returns the value of attribute flags



9
10
11
# File 'lib/spreadsheet/excel/sst_entry.rb', line 9

def flags
  @flags
end

- (Object) phonetic

Returns the value of attribute phonetic



9
10
11
# File 'lib/spreadsheet/excel/sst_entry.rb', line 9

def phonetic
  @phonetic
end

- (Object) richtext

Returns the value of attribute richtext



9
10
11
# File 'lib/spreadsheet/excel/sst_entry.rb', line 9

def richtext
  @richtext
end

- (Object) wide

Returns the value of attribute wide



9
10
11
# File 'lib/spreadsheet/excel/sst_entry.rb', line 9

def wide
  @wide
end

Instance Method Details

- (Object) content

Access the contents of this Shared String



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/spreadsheet/excel/sst_entry.rb', line 20

def content
  @content or begin
    data = nil
    data = @ole[@offset, @available]
    content, _ = @reader.read_string_body data, @flags, @available, @wide
    @continuations.each do |offset, len|
      @reader.continue_string(@ole[offset,len], [content, @chars])
    end
    content = client content, 'UTF-16LE'
    if @reader.memoize?
      @content = content
    end
    content
  end
end

- (Object) continue(offset, size, chars)

Register the offset of a String continuation



37
38
39
40
# File 'lib/spreadsheet/excel/sst_entry.rb', line 37

def continue offset, size, chars
  @continued_chars -= chars
  @continuations.push [offset, size]
end

- (Boolean) continued?

:nodoc:

Returns:

  • (Boolean)


41
42
43
# File 'lib/spreadsheet/excel/sst_entry.rb', line 41

def continued? # :nodoc:
  @continued_chars > 0
end