Class: RubyXL::SharedStrings
- Inherits:
-
Object
- Object
- RubyXL::SharedStrings
- Defined in:
- lib/rubyXL/shared_strings.rb
Instance Attribute Summary collapse
-
#count_attr ⇒ Object
Returns the value of attribute count_attr.
-
#unique_count_attr ⇒ Object
Returns the value of attribute unique_count_attr.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #add(str, index) ⇒ Object
- #empty? ⇒ Boolean
- #get_index(str, add_if_missing = false) ⇒ Object
-
#initialize ⇒ SharedStrings
constructor
A new instance of SharedStrings.
Constructor Details
#initialize ⇒ SharedStrings
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_attr ⇒ Object
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_attr ⇒ Object
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
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 |