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

#initialize(opts = {}) ⇒ SstEntry

Returns 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

#availableObject

Returns the value of attribute available.



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

def available
  @available
end

#charsObject

Returns the value of attribute chars.



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

def chars
  @chars
end

#continued_charsObject

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

#flagsObject

Returns the value of attribute flags.



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

def flags
  @flags
end

#phoneticObject

Returns the value of attribute phonetic.



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

def phonetic
  @phonetic
end

#richtextObject

Returns the value of attribute richtext.



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

def richtext
  @richtext
end

#wideObject

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

#contentObject

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

#continue(offset, size, chars) ⇒ Object

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

#continued?Boolean

:nodoc:

Returns:

  • (Boolean)


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

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