class OoxmlParser::Relationships
Class for describing list of relationships
Attributes
relationship[RW]
@return [Array, Relationship] array of relationships
Public Class Methods
new(parent: nil)
click to toggle source
Calls superclass method
OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/common_parser/common_data/relationships.rb, line 10 def initialize(parent: nil) @relationship = [] super end
Public Instance Methods
[](key)
click to toggle source
@return [Array, Column] accessor for relationship
# File lib/ooxml_parser/common_parser/common_data/relationships.rb, line 16 def [](key) @relationship[key] end
parse(node)
click to toggle source
Parse Relationships
@param [Nokogiri::XML:Node] node with Relationships
@return [Relationships] result of parsing
# File lib/ooxml_parser/common_parser/common_data/relationships.rb, line 23 def parse(node) node.xpath('*').each do |node_children| case node_children.name when 'Relationship' @relationship << Relationship.new(parent: self).parse(node_children) end end self end
parse_file(file_path)
click to toggle source
Parse .rels file @param file_path [String] path to file @return [Relationships]
# File lib/ooxml_parser/common_parser/common_data/relationships.rb, line 36 def parse_file(file_path) node = parse_xml(file_path) node.xpath('*').each do |node_child| case node_child.name when 'Relationships' parse(node_child) end end self end
target_by_id(id)
click to toggle source
Get target name by id @param id [String] id of target @return [String] target name
# File lib/ooxml_parser/common_parser/common_data/relationships.rb, line 50 def target_by_id(id) @relationship.each do |cur_rels| return cur_rels.target if cur_rels.id == id end nil end
target_by_type(type)
click to toggle source
Get target names by type @param type [String] type of target @return [Array<String>] target names
# File lib/ooxml_parser/common_parser/common_data/relationships.rb, line 60 def target_by_type(type) result = [] @relationship.each do |cur_rels| result << cur_rels.target if cur_rels.type.include?(type) end result end