class RubyXL::SharedStringsTable

www.datypic.com/sc/ooxml/e-ssml_sst.html

Constants

CONTENT_TYPE
REL_TYPE

Public Class Methods

new(*params) click to toggle source
Calls superclass method RubyXL::OOXMLObjectInstanceMethods.new
# File lib/rubyXL/objects/shared_strings.rb, line 20
def initialize(*params)
  super
  # 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.
  @index_by_content = {}
end

Public Instance Methods

[](index) click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 34
def [](index)
  strings[index]
end
add(v, index = nil) click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 42
def add(v, index = nil)
  index ||= strings.size

  strings[index] =
    case v
    when RubyXL::RichText then v
    when String then RubyXL::RichText.new(:t => RubyXL::Text.new(:value => v))
    when RubyXL::Text               then RubyXL::RichText.new(:t => v)
    when RubyXL::RichTextRun        then RubyXL::RichText.new(:r => [ v ])
    when RubyXL::PhoneticRun        then RubyXL::RichText.new(:r_ph => [ v ])
    when RubyXL::PhoneticProperties then RubyXL::RichText.new(:phonetic_pr => v)
    end

  @index_by_content[v.to_s] = index
end
before_write_xml() click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 28
def before_write_xml
  super
  self.unique_count = self.count
  self.count > 0
end
empty?() click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 38
def empty?
  strings.empty?
end
get_index(str, add_if_missing = false) click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 58
def get_index(str, add_if_missing = false)
  index = @index_by_content[str]
  index = add(str) if index.nil? && add_if_missing
  index
end
xlsx_path() click to toggle source
# File lib/rubyXL/objects/shared_strings.rb, line 64
def xlsx_path
  ROOT.join('xl', 'sharedStrings.xml')
end