Class: RubyXL::SharedStringsTable
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
#add_to_zip, #filepath, parse_file, set_namespaces
#define_attribute, #define_child_node, #define_element_name, #obtain_class_variable, #parse, #set_countable
#dup, #index_in_collection, #write_xml
Constructor Details
Returns a new instance of SharedStringsTable.
17
18
19
20
21
22
23
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 17
def initialize(*params)
super
@index_by_content = {}
end
|
Class Method Details
.filepath ⇒ Object
51
52
53
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 51
def self.filepath
File.join('xl', 'sharedStrings.xml')
end
|
Instance Method Details
#[](index) ⇒ Object
31
32
33
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 31
def [](index)
strings[index]
end
|
#add(str, index = nil) ⇒ Object
39
40
41
42
43
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 39
def add(str, index = nil)
index ||= strings.size
strings[index] = RubyXL::Text.new(:value => str)
@index_by_content[str] = index
end
|
#before_write_xml ⇒ Object
25
26
27
28
29
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 25
def before_write_xml
super
self.unique_count = self.count
self.count > 0
end
|
#empty? ⇒ Boolean
35
36
37
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 35
def empty?
strings.empty?
end
|
#get_index(str, add_if_missing = false) ⇒ Object
45
46
47
48
49
|
# File 'lib/rubyXL/objects/shared_strings.rb', line 45
def get_index(str, add_if_missing = false)
index = @index_by_content[str]
index = add(str) if index.nil? && add_if_missing
index
end
|