diff options
| author | Randy Morgan <[email protected]> | 2013-01-15 21:53:47 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2013-01-15 21:53:47 +0900 |
| commit | 40c85619885de848447479b99c08e5feaea89a90 (patch) | |
| tree | 61cebfceb3ac1d404e4893b376f9f3a5d72e3bd0 /lib/axlsx/drawing/drawing.rb | |
| parent | e14682fb484cd72ba5f479cc1f7d46a7a9fd6007 (diff) | |
| download | caxlsx-40c85619885de848447479b99c08e5feaea89a90.tar.gz caxlsx-40c85619885de848447479b99c08e5feaea89a90.zip | |
Refactored relationship management for drawings
This should fix #160
Diffstat (limited to 'lib/axlsx/drawing/drawing.rb')
| -rw-r--r-- | lib/axlsx/drawing/drawing.rb | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/axlsx/drawing/drawing.rb b/lib/axlsx/drawing/drawing.rb index 769d67c5..7eaf29b6 100644 --- a/lib/axlsx/drawing/drawing.rb +++ b/lib/axlsx/drawing/drawing.rb @@ -132,6 +132,7 @@ module Axlsx end # The relational part name for this drawing + # #NOTE This should be rewritten to return an Axlsx::Relationship object. # @return [String] def rels_pn "#{DRAWING_RELS_PN % (index+1)}" @@ -139,23 +140,17 @@ module Axlsx # The index of a chart, image or hyperlink object this drawing contains def index_of(object) - objects = charts + images + hyperlinks - objects.index(object) + child_objects.index(object) end + def child_objects + charts + images + hyperlinks + end # The drawing's relationships. # @return [Relationships] def relationships r = Relationships.new - charts.each do |chart| - r << Relationship.new(CHART_R, "../#{chart.pn}") - end - images.each do |image| - r << Relationship.new(IMAGE_R, "../#{image.pn}") - end - hyperlinks.each do |hyperlink| - r << Relationship.new(HYPERLINK_R, hyperlink.href, :target_mode => :External) - end + child_objects.each { |child| r << child.relationship } r end |
