Sha256: 5dbe6757b6ba13286f4fedf2d676bea47f4c3c379b76cdbaaac38a4763f3b993

Contents?: true

Size: 621 Bytes

Versions: 6

Compression:

Stored size: 621 Bytes

Contents

# frozen_string_literal: true

require 'roo/excelx/extractor'

module Roo
  class Excelx
    class Relationships < Excelx::Extractor
      def [](index)
        to_a[index]
      end

      def to_a
        @relationships ||= extract_relationships
      end

      def include_type?(type)
        to_a.any? do |_, rel|
          rel["Type"]&.include? type
        end
      end

      private

      def extract_relationships
        return {} unless doc_exists?

        doc.xpath('/Relationships/Relationship').each_with_object({}) do |rel, hash|
          hash[rel['Id']] = rel
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
roo-2.10.1 lib/roo/excelx/relationships.rb
roo-2.10.0 lib/roo/excelx/relationships.rb
roo-2.9.0 lib/roo/excelx/relationships.rb
ruh-roo-3.0.1 lib/roo/excelx/relationships.rb
roo-2.8.3 lib/roo/excelx/relationships.rb
roo-2.8.2 lib/roo/excelx/relationships.rb