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 ⇒ Object
Returns the value of attribute action.
-
#action_link ⇒ Object
Returns the value of attribute action_link.
-
#coordinates ⇒ Object
Returns the value of attribute coordinates.
-
#highlight_click ⇒ Object
Returns the value of attribute highlight_click.
-
#id ⇒ Object
Returns the value of attribute id.
-
#runs ⇒ Array<ParagraphRun>
readonly
Run of paragraph.
-
#tooltip ⇒ Object
Returns the value of attribute tooltip.
-
#url ⇒ Object
(also: #link, #link_to)
Returns the value of attribute url.
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
#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(link = nil, tooltip = nil, coordinates = nil, parent: nil) ⇒ Hyperlink
Returns a new instance of Hyperlink.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 10 def initialize(link = nil, tooltip = nil, coordinates = nil, parent: nil) @url = link @tooltip = tooltip @coordinates = coordinates @parent = parent @runs = [] end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 4 def action @action end |
#action_link ⇒ Object
Returns the value of attribute action_link.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 5 def action_link @action_link end |
#coordinates ⇒ Object
Returns the value of attribute coordinates.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 4 def coordinates @coordinates end |
#highlight_click ⇒ Object
Returns the value of attribute highlight_click.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 4 def highlight_click @highlight_click end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 6 def id @id end |
#runs ⇒ Array<ParagraphRun> (readonly)
Returns run of paragraph.
8 9 10 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 8 def runs @runs end |
#tooltip ⇒ Object
Returns the value of attribute tooltip.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 4 def tooltip @tooltip end |
#url ⇒ Object Also known as: link, link_to
Returns the value of attribute url.
4 5 6 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 4 def url @url end |
Instance Method Details
#parse(node) ⇒ Hyperlink
Parse Hyperlink object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 29 def parse(node) node.attributes.each do |key, value| case key when 'location' @url = Coordinates.parse_coordinates_from_string(value.value) when 'id' @id = value.value @url = OOXMLDocumentObject.get_link_from_rels(@id) when 'tooltip' @tooltip = value.value when 'ref' @coordinates = Coordinates.parse_coordinates_from_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 @url = OOXMLDocumentObject.get_link_from_rels(@id).scan(/\d+/).join('').to_i else unless @id.nil? @action = :external_link @url = OOXMLDocumentObject.get_link_from_rels(@id) end end self end |