Class: Writexlsx::Package::SharedStrings
- Inherits:
-
Object
- Object
- Writexlsx::Package::SharedStrings
show all
- Includes:
- Utility::XmlPrimitives
- Defined in:
- lib/write_xlsx/package/shared_strings.rb
Constant Summary
collapse
- PRESERVE_SPACE_ATTRIBUTES =
['xml:space', 'preserve'].freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
#r_id_attributes, #write_color, #write_xml_declaration, #xml_str
Constructor Details
Returns a new instance of SharedStrings.
16
17
18
19
20
21
22
|
# File 'lib/write_xlsx/package/shared_strings.rb', line 16
def initialize
@writer = Package::XMLWriterSimple.new
@strings = [] @strings_index = {} @count = 0 @str_unique = 0
end
|
Instance Attribute Details
#strings ⇒ Object
Returns the value of attribute strings.
14
15
16
|
# File 'lib/write_xlsx/package/shared_strings.rb', line 14
def strings
@strings
end
|
Instance Method Details
#add(string) ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/write_xlsx/package/shared_strings.rb', line 29
def add(string)
unless @strings_index[string]
str = string.frozen? ? string : string.freeze
@strings << str
@str_unique += 1
@strings_index[str] = @strings.size - 1
end
@count += 1
end
|
#assemble_xml_file ⇒ Object
51
52
53
54
55
56
|
# File 'lib/write_xlsx/package/shared_strings.rb', line 51
def assemble_xml_file
write_xml_declaration do
write_sst { write_sst_strings }
end
end
|
#empty? ⇒ Boolean
43
44
45
|
# File 'lib/write_xlsx/package/shared_strings.rb', line 43
def empty?
@strings.empty?
end
|
#index(string, params = {}) ⇒ Object
24
25
26
27
|
# File 'lib/write_xlsx/package/shared_strings.rb', line 24
def index(string, params = {})
add(string) unless params[:only_query]
@strings_index[string]
end
|
#set_xml_writer(filename) ⇒ Object
47
48
49
|
# File 'lib/write_xlsx/package/shared_strings.rb', line 47
def set_xml_writer(filename)
@writer.set_xml_writer(filename)
end
|
#string(index) ⇒ Object
39
40
41
|
# File 'lib/write_xlsx/package/shared_strings.rb', line 39
def string(index)
@strings[index]
end
|