Class: OoxmlParser::Hyperlink
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Hyperlink
- Defined in:
- lib/ooxml_parser/common_parser/common_data/hyperlink.rb
Overview
Class for parsing ‘hlinkClick`, `hyperlink` tags
Instance Attribute Summary collapse
-
#action ⇒ Symbol
readonly
Type of action.
-
#action_link ⇒ String
readonly
Value of action link.
-
#anchor ⇒ String
readonly
Anchor value.
-
#coordinates ⇒ Coordinates
readonly
Coordinates of link.
-
#highlight_click ⇒ True, False
readonly
Should click be highlighted.
-
#id ⇒ String
readonly
Id of link.
-
#runs ⇒ Array<ParagraphRun>
readonly
Run of paragraph.
-
#tooltip ⇒ String
readonly
Tooltip value.
-
#url ⇒ OOXMLDocumentObject
(also: #link, #link_to)
Url of hyperlink.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(link = nil, tooltip = nil, coordinates = nil, parent: nil) ⇒ Hyperlink
constructor
A new instance of Hyperlink.
-
#parse(node) ⇒ Hyperlink
Parse Hyperlink object.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(link = nil, tooltip = nil, coordinates = nil, parent: nil) ⇒ Hyperlink
Returns a new instance of Hyperlink.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 25 def initialize(link = nil, tooltip = nil, coordinates = nil, parent: nil) @url = link @tooltip = tooltip @coordinates = coordinates @runs = [] super(parent: parent) end |
Instance Attribute Details
#action ⇒ Symbol (readonly)
Returns type of action.
17 18 19 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 17 def action @action end |
#action_link ⇒ String (readonly)
Returns value of action link.
19 20 21 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 19 def action_link @action_link end |
#anchor ⇒ String (readonly)
Returns anchor value.
7 8 9 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 7 def anchor @anchor end |
#coordinates ⇒ Coordinates (readonly)
Returns coordinates of link.
13 14 15 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 13 def coordinates @coordinates end |
#highlight_click ⇒ True, False (readonly)
Returns should click be highlighted.
15 16 17 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 15 def highlight_click @highlight_click end |
#id ⇒ String (readonly)
Returns id of link.
21 22 23 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 21 def id @id end |
#runs ⇒ Array<ParagraphRun> (readonly)
Returns run of paragraph.
23 24 25 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 23 def runs @runs end |
#tooltip ⇒ String (readonly)
Returns tooltip value.
11 12 13 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 11 def tooltip @tooltip end |
#url ⇒ OOXMLDocumentObject Also known as: link, link_to
Returns url of hyperlink.
9 10 11 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 9 def url @url end |
Instance Method Details
#parse(node) ⇒ Hyperlink
Parse Hyperlink object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 44 def parse(node) node.attributes.each do |key, value| case key when 'anchor' @anchor = value.value when 'location' @url = Coordinates.new.parse_string(value.value) when 'id' @id = value.value @url = root_object.get_link_from_rels(@id) unless @id.empty? when 'tooltip' @tooltip = value.value when 'ref' @coordinates = Coordinates.new.parse_string(value.value) when 'action' @action_link = value.value when 'highlightClick' @highlight_click = attribute_enabled?(value) end end node.xpath('*').each do |node_child| case node_child.name when 'r' @runs << ParagraphRun.new(parent: self).parse(node_child) end end case @action_link when 'ppaction://hlinkshowjump?jump=previousslide' @action = :previous_slide when 'ppaction://hlinkshowjump?jump=nextslide' @action = :next_slide when 'ppaction://hlinkshowjump?jump=firstslide' @action = :first_slide when 'ppaction://hlinkshowjump?jump=lastslide' @action = :last_slide when 'ppaction://hlinksldjump' @action = :slide else if meaningful_id? @action = :external_link @url = root_object.get_link_from_rels(@id) end end self end |