Class: RubyXL::SharedStrings

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSharedStrings

Returns a new instance of SharedStrings.



6
7
8
9
10
11
12
13
# File 'lib/rubyXL/shared_strings.rb', line 6

def initialize
  # So far, going by the structure that the original creator had in mind. However, 
  # since the actual implementation is now extracted into a separate class, 
  # we will be able to transparrently change it later if needs be.
  @content_by_index = []
  @index_by_content = {}
  @unique_count_attr = @count_attr = nil # TODO
end

Instance Attribute Details

#count_attrObject

Returns the value of attribute count_attr.



4
5
6
# File 'lib/rubyXL/shared_strings.rb', line 4

def count_attr
  @count_attr
end

#unique_count_attrObject

Returns the value of attribute unique_count_attr.



4
5
6
# File 'lib/rubyXL/shared_strings.rb', line 4

def unique_count_attr
  @unique_count_attr
end

Instance Method Details

#[](index) ⇒ Object



30
31
32
# File 'lib/rubyXL/shared_strings.rb', line 30

def[](index)
  @content_by_index[index]
end

#add(str, index) ⇒ Object



19
20
21
22
# File 'lib/rubyXL/shared_strings.rb', line 19

def add(str, index)
  @content_by_index[index] = str
  @index_by_content[str] = index
end

#empty?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rubyXL/shared_strings.rb', line 15

def empty?
  @content_by_index.empty?
end

#get_index(str, add_if_missing = false) ⇒ Object



24
25
26
27
28
# File 'lib/rubyXL/shared_strings.rb', line 24

def get_index(str, add_if_missing = false)
  index = @index_by_content[str]
  index = add(str) if index.nil? && add_if_missing
  index 
end