Class: Writexlsx::Worksheet::InternalHyperlink

Inherits:
Hyperlink
  • Object
show all
Defined in:
lib/write_xlsx/worksheet/hyperlink.rb

Constant Summary

Constants inherited from Hyperlink

Hyperlink::MAXIMUM_URLS_SIZE

Constants included from Constants

Constants::COL_MAX, Constants::ROW_MAX, Constants::SHEETNAME_MAX, Constants::STR_MAX

Constants included from Utility::Common

Utility::Common::PERL_TRUE_VALUES

Instance Attribute Summary

Attributes inherited from Hyperlink

#str, #tip

Instance Method Summary collapse

Methods inherited from Hyperlink

#display_on, #external_hyper_link, factory

Methods included from Utility::XmlPrimitives

#r_id_attributes, #write_color, #write_xml_declaration, #xml_str

Methods included from Utility::Url

#escape_url

Methods included from Utility::CellReference

#row_col_notation, #substitute_cellref, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell

Methods included from Utility::Common

#absolute_char, #check_parameter, #float_to_str, #ptrue?, #put_deprecate_message

Constructor Details

#initialize(url, str, tip, max_url_length) ⇒ InternalHyperlink

Returns a new instance of InternalHyperlink.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/write_xlsx/worksheet/hyperlink.rb', line 77

def initialize(url, str, tip, max_url_length)
  @url = url
  # The displayed string defaults to the url string.
  str ||= @url.dup

  # Strip the mailto header.
  @str = str.sub(/^mailto:/, '')

  # Copy string for use in hyperlink elements.
  @url_str = @str.dup

  # Excel limits escaped URL to #{max_url_length} characters.
  raise "URL '#{@url}' > #{max_url_length} characters, it exceeds Excel's limit for URLS." if @url.bytesize > max_url_length

  @tip = tip
end

Instance Method Details

#attributes(row, col, _dummy = nil) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'lib/write_xlsx/worksheet/hyperlink.rb', line 94

def attributes(row, col, _dummy = nil)
  attr = [
    ['ref', xl_rowcol_to_cell(row, col)],
    ['location', @url]
  ]

  attr << ['tooltip', @tip] if @tip
  attr << ['display', @str]
end