Class: OoxmlParser::Hyperlink
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Hyperlink
- Defined in:
- lib/ooxml_parser/common_parser/common_data/hyperlink.rb
Constant Summary
Constants inherited from OOXMLDocumentObject
OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#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.
-
#tooltip ⇒ Object
Returns the value of attribute tooltip.
-
#url ⇒ Object
(also: #link, #link_to)
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(link = nil, tooltip = nil, coordinates = nil) ⇒ Hyperlink
constructor
A new instance of Hyperlink.
Methods inherited from OOXMLDocumentObject
#==, add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file
Constructor Details
#initialize(link = nil, tooltip = nil, coordinates = nil) ⇒ Hyperlink
Returns a new instance of Hyperlink.
5 6 7 8 9 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 5 def initialize(link = nil, tooltip = nil, coordinates = nil) @url = link @tooltip = tooltip @coordinates = coordinates end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
3 4 5 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 3 def action @action end |
#coordinates ⇒ Object
Returns the value of attribute coordinates.
3 4 5 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 3 def coordinates @coordinates end |
#highlight_click ⇒ Object
Returns the value of attribute highlight_click.
3 4 5 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 3 def highlight_click @highlight_click end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 3 def id @id end |
#tooltip ⇒ Object
Returns the value of attribute tooltip.
3 4 5 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 3 def tooltip @tooltip end |
#url ⇒ Object Also known as: link, link_to
Returns the value of attribute url.
3 4 5 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 3 def url @url end |
Class Method Details
.parse(on_click_hyperlink_node) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 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 |
# File 'lib/ooxml_parser/common_parser/common_data/hyperlink.rb', line 16 def self.parse(on_click_hyperlink_node) hyperlink = Hyperlink.new on_click_hyperlink_node.attributes.each do |key, value| case key when 'location' hyperlink.url = Coordinates.parse_coordinates_from_string(value.value) when 'id' hyperlink.url = OOXMLDocumentObject.get_link_from_rels(on_click_hyperlink_node.attribute('id').value) when 'tooltip' hyperlink.tooltip = value.value when 'ref' hyperlink.coordinates = Coordinates.parse_coordinates_from_string(value.value) end end action = on_click_hyperlink_node.attribute('action').value unless on_click_hyperlink_node.attribute('action').nil? case action when 'ppaction://hlinkshowjump?jump=previousslide' hyperlink.action = :previous_slide when 'ppaction://hlinkshowjump?jump=nextslide' hyperlink.action = :next_slide when 'ppaction://hlinkshowjump?jump=firstslide' hyperlink.action = :first_slide when 'ppaction://hlinkshowjump?jump=lastslide' hyperlink.action = :last_slide when 'ppaction://hlinksldjump' hyperlink.action = :slide hyperlink.link_to = OOXMLDocumentObject.get_link_from_rels(on_click_hyperlink_node.attribute('id').value).scan(/\d+/).join('').to_i else unless on_click_hyperlink_node.attribute('id').nil? hyperlink.action = :external_link hyperlink.link_to = OOXMLDocumentObject.get_link_from_rels(on_click_hyperlink_node.attribute('id').value) end end return hyperlink unless on_click_hyperlink_node.attribute('highlightClick') hyperlink.highlight_click = if on_click_hyperlink_node.attribute('highlightClick').value == '1' true else false end hyperlink end |