Class: OOXL::Relationships

Inherits:
Object
  • Object
show all
Defined in:
lib/ooxl/xl_objects/relationships.rb

Defined Under Namespace

Classes: Relationship

Constant Summary collapse

SUPPORTED_TYPES =
['http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments']

Instance Method Summary collapse

Constructor Details

#initialize(relationships_node) ⇒ Relationships

Returns a new instance of Relationships.



5
6
7
8
# File 'lib/ooxl/xl_objects/relationships.rb', line 5

def initialize(relationships_node)
  @relationships = []
  parse_relationships(relationships_node)
end

Instance Method Details

#[](id) ⇒ Object



15
16
17
# File 'lib/ooxl/xl_objects/relationships.rb', line 15

def [](id)
  @relationships.find { |rel| rel.id == id }&.target
end

#by_type(type) ⇒ Object



19
20
21
# File 'lib/ooxl/xl_objects/relationships.rb', line 19

def by_type(type)
  @relationships.select { |rel| rel.type == type }.map(&:target)
end

#comment_idObject



10
11
12
13
# File 'lib/ooxl/xl_objects/relationships.rb', line 10

def comment_id
  comment_target = by_type('comments').first
  comment_target && extract_file_reference(comment_target)
end