Sha256: 3e244f83cbb9f7c7e6bb9dc81272d3e22fa9ef1ba1124cefb827cbedcce98575

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Axlsx
  # A collection of hyperlink objects for a worksheet
  class WorksheetHyperlinks < SimpleTypedList
    # Creates a new Hyperlinks collection
    # @param [Worksheet] worksheet the worksheet that owns these hyperlinks
    def initialize(worksheet)
      DataTypeValidator.validate "Hyperlinks.worksheet", [Worksheet], worksheet
      @worksheet = worksheet
      super WorksheetHyperlink
    end

    # Creates and adds a new hyperlink based on the options provided
    # @see WorksheetHyperlink#initialize
    # @return [WorksheetHyperlink]
    def add(options)
      self << WorksheetHyperlink.new(@worksheet, options)
      last
    end

    # The relationships required by this collection's hyperlinks
    # @return Array
    def relationships
      return [] if empty?

      map(&:relationship)
    end

    # seralize the collection of hyperlinks
    # @return [String]
    def to_xml_string(str = +'')
      return if empty?

      str << '<hyperlinks>'
      each { |hyperlink| hyperlink.to_xml_string(str) }
      str << '</hyperlinks>'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caxlsx-4.0.0 lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb