class RubyXL::OOXMLRelationshipsFile

Constants

SAVE_ORDER

Attributes

owner[RW]

Public Class Methods

get_class_by_rel_type(rel_type) click to toggle source
# File lib/rubyXL/objects/relationships.rb, line 51
def self.get_class_by_rel_type(rel_type)
  unless defined?(@@rel_hash)
    @@rel_hash = {}
    RubyXL.constants.each { |c|
      klass = RubyXL.const_get(c)

      if klass.is_a?(Class) && klass.const_defined?(:REL_TYPE) then
        @@rel_hash[klass::REL_TYPE] = klass
      end
    }
  end

  @@rel_hash[rel_type]
end
load_relationship_file(zipdir_path, base_file_path) click to toggle source
# File lib/rubyXL/objects/relationships.rb, line 99
def self.load_relationship_file(zipdir_path, base_file_path)
  rel_file_path = Pathname.new(File.join(File.dirname(base_file_path), '_rels', File.basename(base_file_path) + '.rels')).cleanpath

  puts "--> DEBUG:  #{'  ' * @@debug}Loading .rel file: #{rel_file_path}" if @@debug

  parse_file(zipdir_path, rel_file_path)
end

Public Instance Methods

find_by_rid(r_id) click to toggle source
# File lib/rubyXL/objects/relationships.rb, line 43
def find_by_rid(r_id)
  relationships.find { |r| r.id == r_id }
end
find_by_target(target) click to toggle source
# File lib/rubyXL/objects/relationships.rb, line 47
def find_by_target(target)
  relationships.find { |r| r.target == target }
end
xlsx_path() click to toggle source
# File lib/rubyXL/objects/relationships.rb, line 107
def xlsx_path
  file_path = owner.xlsx_path
  File.join(File.dirname(file_path), '_rels', File.basename(file_path) + '.rels')
end

Protected Instance Methods

add_relationship(obj) click to toggle source
# File lib/rubyXL/objects/relationships.rb, line 35
def add_relationship(obj)
  return if obj.nil?
  relationships << RubyXL::Relationship.new(:id => "rId#{relationships.size + 1}", 
                                            :type => obj.class::REL_TYPE,
                                            :target => obj.xlsx_path)
end
new_relationship(target, type) click to toggle source
# File lib/rubyXL/objects/relationships.rb, line 28
def new_relationship(target, type)
  RubyXL::Relationship.new(:id => "rId#{relationships.size + 1}", 
                           :type => type,
                           :target => target)
end