Class: Axlsx::WorksheetHyperlinks

Inherits:
SimpleTypedList
  • Object
show all
Defined in:
lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb

Overview

A collection of hyperlink objects for a worksheet

Instance Method Summary collapse

Constructor Details

#initialize(worksheet) ⇒ WorksheetHyperlinks

Creates a new Hyperlinks collection

Parameters:

  • worksheet (Worksheet)

    the worksheet that owns these hyperlinks



8
9
10
11
12
# File 'lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb', line 8

def initialize(worksheet)
  DataTypeValidator.validate "Hyperlinks.worksheet", [Worksheet], worksheet
  @worksheet = worksheet
  super WorksheetHyperlink
end

Instance Method Details

#add(options) ⇒ WorksheetHyperlink

Creates and adds a new hyperlink based on the options provided



17
18
19
20
# File 'lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb', line 17

def add(options)
  self << WorksheetHyperlink.new(@worksheet, options)
  last
end

#relationshipsObject

The relationships required by this collection’s hyperlinks

Returns:

  • Array



24
25
26
27
# File 'lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb', line 24

def relationships
  return [] if empty?
  map { |hyperlink| hyperlink.relationship }
end

#to_xml_string(str = '') ⇒ String

seralize the collection of hyperlinks

Returns:

  • (String)


31
32
33
34
35
36
# File 'lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb', line 31

def to_xml_string(str='')
  return if empty?
  str << '<hyperlinks>'
  each { |hyperlink| hyperlink.to_xml_string(str) }
  str << '</hyperlinks>'
end