Class: Uniword::Docx::ChartPart

Inherits:
Part
  • Object
show all
Defined in:
lib/uniword/docx/chart_part.rb

Overview

A chart part (word/charts/chartN.xml) held by the package.

The content is the raw chart XML String. Replaces the former { xml:, target: } hash entries in chart_parts.

Constant Summary

Constants inherited from Part

Part::HASH_LOOKUP

Instance Attribute Summary

Attributes inherited from Part

#content, #content_type, #definition, #r_id, #rel_type, #target

Instance Method Summary collapse

Methods inherited from Part

#path

Constructor Details

#initialize(r_id: nil, target: nil, content: nil, **rest) ⇒ ChartPart

Returns a new instance of ChartPart.

Parameters:

  • r_id (String, nil) (defaults to: nil)

    relationship id

  • target (String, nil) (defaults to: nil)

    e.g. "charts/chart1.xml"

  • content (String, nil) (defaults to: nil)

    raw chart XML



13
14
15
16
17
18
# File 'lib/uniword/docx/chart_part.rb', line 13

def initialize(r_id: nil, target: nil, content: nil, **rest)
  super(
    definition: Ooxml::PartRegistry.find_by_key(:chart),
    r_id: r_id, target: target, content: content, **rest
  )
end

Instance Method Details

#[](key) ⇒ Object

Hash-style read compatibility (+:xml+ in addition to the Part keys).



29
30
31
# File 'lib/uniword/docx/chart_part.rb', line 29

def [](key)
  key.to_sym == :xml ? content : super
end

#xmlString?

Raw chart XML (alias for content).

Returns:

  • (String, nil)


23
24
25
# File 'lib/uniword/docx/chart_part.rb', line 23

def xml
  content
end