ruby_pptx 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +98 -0
  3. data/README.md +94 -4
  4. data/lib/ruby_pptx/action.rb +12 -4
  5. data/lib/ruby_pptx/autoshape_spec.rb +6 -2
  6. data/lib/ruby_pptx/builder.rb +3 -1
  7. data/lib/ruby_pptx/chart/categories.rb +45 -15
  8. data/lib/ruby_pptx/chart/chart.rb +168 -31
  9. data/lib/ruby_pptx/chart/combo.rb +19 -4
  10. data/lib/ruby_pptx/chart/data.rb +45 -15
  11. data/lib/ruby_pptx/chart/format.rb +229 -76
  12. data/lib/ruby_pptx/chart/workbook_writer.rb +9 -3
  13. data/lib/ruby_pptx/chart/xml_writer.rb +54 -18
  14. data/lib/ruby_pptx/chart/xy_data.rb +68 -22
  15. data/lib/ruby_pptx/dml/color.rb +27 -9
  16. data/lib/ruby_pptx/dml/effect.rb +6 -2
  17. data/lib/ruby_pptx/dml/fill.rb +42 -14
  18. data/lib/ruby_pptx/element_proxy.rb +12 -4
  19. data/lib/ruby_pptx/enum/base.rb +30 -10
  20. data/lib/ruby_pptx/enum/prog_id.rb +3 -1
  21. data/lib/ruby_pptx/geometry.rb +32 -10
  22. data/lib/ruby_pptx/image.rb +27 -9
  23. data/lib/ruby_pptx/length.rb +94 -27
  24. data/lib/ruby_pptx/media.rb +12 -4
  25. data/lib/ruby_pptx/numeric_lengths.rb +34 -9
  26. data/lib/ruby_pptx/opc/oxml.rb +7 -5
  27. data/lib/ruby_pptx/opc/pack_uri.rb +15 -5
  28. data/lib/ruby_pptx/opc/package.rb +97 -31
  29. data/lib/ruby_pptx/opc/serialized.rb +15 -5
  30. data/lib/ruby_pptx/oxml/backend.rb +585 -0
  31. data/lib/ruby_pptx/oxml/chart.rb +112 -42
  32. data/lib/ruby_pptx/oxml/content_model.rb +6 -2
  33. data/lib/ruby_pptx/oxml/dml/color.rb +6 -2
  34. data/lib/ruby_pptx/oxml/dml/fill.rb +6 -2
  35. data/lib/ruby_pptx/oxml/element.rb +138 -101
  36. data/lib/ruby_pptx/oxml/ns.rb +7 -7
  37. data/lib/ruby_pptx/oxml/presentation.rb +9 -3
  38. data/lib/ruby_pptx/oxml/section.rb +3 -1
  39. data/lib/ruby_pptx/oxml/shapes/autoshape.rb +39 -13
  40. data/lib/ruby_pptx/oxml/shapes/groupshape.rb +15 -7
  41. data/lib/ruby_pptx/oxml/shapes/other.rb +47 -16
  42. data/lib/ruby_pptx/oxml/shapes/shared.rb +96 -30
  43. data/lib/ruby_pptx/oxml/simple_types.rb +169 -52
  44. data/lib/ruby_pptx/oxml/slide.rb +25 -8
  45. data/lib/ruby_pptx/oxml/table.rb +39 -13
  46. data/lib/ruby_pptx/oxml/text.rb +122 -16
  47. data/lib/ruby_pptx/oxml/theme.rb +13 -4
  48. data/lib/ruby_pptx/package.rb +9 -3
  49. data/lib/ruby_pptx/parts/chart.rb +6 -2
  50. data/lib/ruby_pptx/parts/image.rb +12 -4
  51. data/lib/ruby_pptx/parts/media.rb +3 -1
  52. data/lib/ruby_pptx/parts/presentation.rb +15 -5
  53. data/lib/ruby_pptx/parts/slide.rb +33 -11
  54. data/lib/ruby_pptx/parts/theme.rb +3 -1
  55. data/lib/ruby_pptx/pattern_matching.rb +6 -2
  56. data/lib/ruby_pptx/presentation.rb +24 -8
  57. data/lib/ruby_pptx/section.rb +30 -10
  58. data/lib/ruby_pptx/shapes/adjustments.rb +9 -3
  59. data/lib/ruby_pptx/shapes/authoring.rb +3 -1
  60. data/lib/ruby_pptx/shapes/base.rb +74 -24
  61. data/lib/ruby_pptx/shapes/freeform.rb +36 -12
  62. data/lib/ruby_pptx/shapes/placeholder.rb +44 -15
  63. data/lib/ruby_pptx/shapes/shape.rb +91 -30
  64. data/lib/ruby_pptx/shapes/shape_tree.rb +235 -121
  65. data/lib/ruby_pptx/slide.rb +137 -46
  66. data/lib/ruby_pptx/table.rb +105 -35
  67. data/lib/ruby_pptx/text/font_metrics.rb +30 -9
  68. data/lib/ruby_pptx/text/list_style.rb +88 -0
  69. data/lib/ruby_pptx/text/text.rb +241 -59
  70. data/lib/ruby_pptx/theme.rb +30 -10
  71. data/lib/ruby_pptx/version.rb +1 -1
  72. data/lib/ruby_pptx.rb +9 -1
  73. metadata +24 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cd5ac8827fcd5b81d86a1b0a0faa9f619f776dd005580589bbe88fd3f666d4a
4
- data.tar.gz: 6dafdf4a15d53bb8d4a795d3e2c0a18beebab2bd35070076d69e2a7cddddd29f
3
+ metadata.gz: caa0d099f2d7cc089e42e00d1537c798a986ff4c2f84c8dbb0a37df3679b6cfa
4
+ data.tar.gz: 4f629f50f2abce8ce9ebbd9dd02d1869410a2b24c048d9a0f07b9f911557e04e
5
5
  SHA512:
6
- metadata.gz: b54ec7a6115da3d4da42ee124faefb0fee0e51d200525af1c05527fe9a6c579d279ca7da59293ce71b81a56a03c4e1567b228cb86caa234e28f1b0faf44bd9ef
7
- data.tar.gz: 2d991bf2f20c571783f5d1243d586b9e0aa9b4f2db655872c1b60a71ada29495b5e91ab587674e82fa98d34a8cb552e51f5c6fc20b76afa680691cf84bbccce8
6
+ metadata.gz: ed68ccd9fc322871768eb6fab7c3e2967f040293f6cefa1f69afe6bf0d3bd2712afe829959d589102dacf059e31ba57e610d3dae98fedb656853bd17b9ae53b3
7
+ data.tar.gz: 92ad2c28105d022511fbabf307f2c3f5756bc3b22a868d8aa6189489e97d84cafb26748523f39cd6c1913f12b11d157163389de8a23249e4660a7ed1e53af666
data/CHANGELOG.md CHANGED
@@ -5,6 +5,101 @@ All notable changes to this gem are recorded here. The format follows
5
5
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Before 1.0 a minor
6
6
  version may change the public API.
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [0.3.0] - 2026-11-17
11
+
12
+ ### Added
13
+
14
+ - `Paragraph#bullet=` sets a character bullet (`"•"`), an autonumber scheme
15
+ (`:arabicPeriod`), `:none`, or `nil` to inherit; `Paragraph#margin_left=`
16
+ and `Paragraph#indent=` give it a hanging indent. python-pptx has neither.
17
+ - Layouts and masters take the drawing methods slides have: `add_shape`,
18
+ `add_picture` (SVG with raster fallback included), `add_textbox`,
19
+ `add_connector`, `add_freeform`/`build_freeform` and `add_group_shape` on
20
+ `layout.shapes` and `master.shapes`. Every slide on the layout shows them,
21
+ which is how a template carries its logo and bands. Charts, tables, movies
22
+ and OLE objects stay slide-only. The `placeholders` views do not offer
23
+ these methods, since a shape added there would not be listed.
24
+ - `SlideMaster#text_styles` reaches the master's `p:txStyles`: `title`,
25
+ `body` and `other` are `ListStyle`s, and `level(n)` (0 to 8, like
26
+ `Paragraph#level`) or `default` gives a `ParagraphStyle` with the same
27
+ formatting methods as a paragraph -- alignment, spacing, `bullet`,
28
+ `margin_left`, `indent` and `font`. Missing levels are created in schema
29
+ order.
30
+ - `TextFrame#list_style`: the same `ListStyle` for a text body's
31
+ `a:lstStyle`, so a layout placeholder can set what its slides inherit.
32
+ - `Paragraph#add_field(:slide_number)`, `(:date_time)` or any field type
33
+ string such as `"datetime4"`.
34
+ - `TextFrame#text_direction=` with `:vertical_270` (bottom to top),
35
+ `:vertical`, `:stacked` and the East Asian directions.
36
+ - `Font#caps=` with `:all`, `:small`, `:none` or `nil`.
37
+ - `Slides#add(layout, footers: true)` also copies the date, footer and
38
+ slide-number placeholders, text included. PowerPoint only draws them where
39
+ the slide carries them.
40
+ - Shapes drawn on a layout or master get `userDrawn="1"`, as PowerPoint
41
+ writes it.
42
+ - `Chart#replace_data` rebinds scatter charts from an `XyChartData` and
43
+ bubble charts from a `BubbleChartData`: it rewrites each series' `c:tx`,
44
+ `c:xVal`, `c:yVal` and `c:bubbleSize` and keeps its formatting.
45
+ ([#1](https://github.com/Largo/ruby_pptx/issues/1))
46
+
47
+ ### Changed
48
+
49
+ - `Chart#replace_data` on a chart with more than one plot (a combo chart)
50
+ raises `Pptx::Error` when the series count changes. Series are matched to
51
+ plots in document order, so fewer series used to remove whole plots --
52
+ leaving their secondary value axis behind -- and more series were all
53
+ cloned into the last plot. Rebinding with the same number of series works
54
+ as before. ([#2](https://github.com/Largo/ruby_pptx/issues/2))
55
+ - `Chart#replace_data` raises `Pptx::Error` when the data does not fit the
56
+ chart: `ChartData` for a scatter or bubble chart, `XyChartData` for a
57
+ category chart, or `XyChartData` without bubble sizes for a bubble chart.
58
+
59
+ ### Fixed
60
+
61
+ - `Chart#replace_data(ChartData)` on a scatter chart wrote a `c:ser` with
62
+ both `c:val` and the old `c:xVal`/`c:yVal`, which PowerPoint reports as
63
+ unreadable content; it now raises instead. With an `XyChartData` it raised
64
+ `NoMethodError`. ([#1](https://github.com/Largo/ruby_pptx/issues/1))
65
+ - Line series in a combo chart were drawn as smoothed curves: they carried
66
+ no `c:smooth` of their own, which PowerPoint reads as smoothed regardless
67
+ of the plot's setting. Each now writes `<c:smooth val="0"/>`, as a plain
68
+ line chart does; `series.smooth = true` still curves one.
69
+ - The comment on `SlideLayout::LATENT_PLACEHOLDER_TYPES` said PowerPoint
70
+ shows those placeholders from the layout; it does not.
71
+
72
+ ## [0.2.0] - 2026-09-28
73
+
74
+ ### Added
75
+
76
+ - A pure-Ruby XML backend built on REXML, used automatically where Nokogiri
77
+ cannot be loaded -- notably ruby.wasm. It writes the same packages as the
78
+ Nokogiri backend; CI runs every spec under both, and builds, saves and
79
+ rereads a deck inside ruby.wasm. `Pptx.xml_backend` reports which is in
80
+ use, and `RUBY_PPTX_XML_BACKEND` chooses one explicitly.
81
+ - `rexml` is now a runtime dependency. Nokogiri remains one too.
82
+
83
+ ### Changed
84
+
85
+ - `require "ruby_pptx"` no longer requires Nokogiri directly; the XML
86
+ backend loads it.
87
+
88
+ ## [0.1.1] - 2026-09-28
89
+
90
+ ### Fixed
91
+
92
+ - `gem install ruby_pptx` failed on Windows while generating ri
93
+ documentation (`Errno::ENOENT` on a very long `.ri` path). RDoc 7 and
94
+ earlier, which Ruby 3.3 to 4.0 bundle, cannot parse endless method
95
+ definitions (`def x = ...`); each one ended its class early, so every later
96
+ class was documented inside the one before it. On other platforms the
97
+ install succeeded but the ri documentation was wrong. The library no longer
98
+ uses endless methods, and CI checks that RDoc places every class correctly.
99
+ - `Presentation.open(path)` left a file handle open for every member of the
100
+ package until garbage collection, so on Windows the `.pptx` stayed locked
101
+ and could not be deleted or overwritten after opening it.
102
+
8
103
  ## [0.1.0] - 2026-09-28
9
104
 
10
105
  The first release: a Ruby port of [python-pptx](https://github.com/scanny/python-pptx)
@@ -80,4 +175,7 @@ or where matching it cannot be done. Each case is listed, with its reason, in
80
175
  - Getters that write to the document in python-pptx -- data-label flags, axis
81
176
  and chart titles -- do not here.
82
177
 
178
+ [0.3.0]: https://github.com/Largo/ruby_pptx/releases/tag/v0.3.0
179
+ [0.2.0]: https://github.com/Largo/ruby_pptx/releases/tag/v0.2.0
180
+ [0.1.1]: https://github.com/Largo/ruby_pptx/releases/tag/v0.1.1
83
181
  [0.1.0]: https://github.com/Largo/ruby_pptx/releases/tag/v0.1.0
data/README.md CHANGED
@@ -92,6 +92,52 @@ end
92
92
  deck.save("out.pptx")
93
93
  ```
94
94
 
95
+ Speaker notes are plain text for the common case, with the full text frame
96
+ underneath when you want formatting. Reading `notes` never creates a notes
97
+ page; assigning does.
98
+
99
+ ```ruby
100
+ slide.notes = "Mention the Q3 dip.\nThank the team."
101
+ slide.notes #=> "Mention the Q3 dip.\nThank the team."
102
+ slide.notes_slide.notes_text_frame.paragraphs.last.runs.first.font.bold = true
103
+ ```
104
+
105
+ Picture, table and chart placeholders are filled in place, so the content takes
106
+ the layout's position and size. A picture is cropped to fill its placeholder,
107
+ never stretched.
108
+
109
+ ```ruby
110
+ photo = deck.slides.add(deck.slide_layouts["Picture with Caption"])
111
+ photo.placeholders[1].insert_picture("office.jpg")
112
+ photo.placeholders[2].text_frame.text = "Our new office"
113
+
114
+ # The default template has no table or chart placeholders, so add a layout
115
+ # with both to its master.
116
+ layout = deck.slide_masters[0].slide_layouts.add("Table and Chart", type: "twoObj") do |l|
117
+ l.placeholders.add(:title)
118
+ l.placeholders.add(:table, idx: 1, at: [Pptx.inches(0.5), Pptx.inches(1.5)],
119
+ size: [Pptx.inches(4.25), Pptx.inches(4.5)])
120
+ l.placeholders.add(:chart, idx: 2, at: [Pptx.inches(5.25), Pptx.inches(1.5)],
121
+ size: [Pptx.inches(4.25), Pptx.inches(4.5)])
122
+ end
123
+
124
+ report = deck.slides.add(layout)
125
+ report.placeholders[1].insert_table(3, 2).table[0, 0].text = "Region"
126
+ report.placeholders[2].insert_chart(:column_clustered, data)
127
+ ```
128
+
129
+ Any file can be embedded as an OLE object, shown as an icon that opens it when
130
+ double-clicked. Word, Excel and PowerPoint files get Office's own icon; for
131
+ anything else, name its ProgID and optionally supply an icon.
132
+
133
+ ```ruby
134
+ sheet = slide.shapes.add_ole_object("budget.xlsx", prog_id: :xlsx, at: [x, y])
135
+ sheet.ole_format.prog_id #=> "Excel.Sheet.12"
136
+
137
+ slide.shapes.add_ole_object("report.pdf", prog_id: "AcroExch.Document", at: [x, y],
138
+ icon_file: "pdf-icon.png")
139
+ ```
140
+
95
141
  Five things python-pptx does not do: **SVG pictures**, **slide sections**,
96
142
  **paging a long table across as many slides as it needs**, **combo charts**
97
143
  with a secondary axis, and **defining a slide master in code**.
@@ -102,10 +148,19 @@ data.categories = %w[Q1 Q2 Q3]
102
148
  data.add_series("Revenue", [120, 135, 150])
103
149
  data.add_series("Margin", [0.21, 0.24, 0.22])
104
150
 
105
- slide.shapes.add_combo_chart(data, at: [x, y], size: [w, h]) do |combo|
151
+ chart = slide.shapes.add_combo_chart(data, at: [x, y], size: [w, h]) do |combo|
106
152
  combo.plot :column_clustered, series: "Revenue"
107
153
  combo.plot :line, series: "Margin", secondary_axis: true
108
- end
154
+ end.chart
155
+
156
+ # Lines are drawn straight. Smoothing is a per-series setting, as in
157
+ # PowerPoint's "Smoothed line" checkbox, and replace_data keeps it.
158
+ chart.series.last.smooth = true
159
+
160
+ # replace_data matches series to plots in order, so on a combo chart the
161
+ # series count must stay the same; a different count raises Pptx::Error
162
+ # rather than dropping a plot or its secondary axis.
163
+ chart.replace_data(new_data_with_two_series)
109
164
  ```
110
165
 
111
166
  ```ruby
@@ -213,6 +268,36 @@ end
213
268
  Collections index like arrays — `slides[2]`, `slides[-1]`, `slides[1..3]`,
214
269
  `slides[1, 2]` — and deconstruct into array patterns.
215
270
 
271
+ ## Nokogiri, REXML and ruby.wasm
272
+
273
+ ruby_pptx reads and writes XML with Nokogiri. Where Nokogiri cannot load --
274
+ ruby.wasm, in a browser or elsewhere -- it falls back to REXML, which is pure
275
+ Ruby, with no configuration:
276
+
277
+ ```ruby
278
+ Pptx.xml_backend #=> :nokogiri, or :rexml without Nokogiri
279
+ ```
280
+
281
+ The output does not depend on the backend: CI runs every spec under both, and
282
+ the packages they write are identical part for part. REXML is slower -- in a
283
+ 60-slide deck with text, tables and charts, about 3.3 s against 0.5 s to build
284
+ and save, and 0.7 s against 0.1 s to open and read it back. Set
285
+ `RUBY_PPTX_XML_BACKEND=rexml` (or `nokogiri`) to choose explicitly.
286
+
287
+ Nokogiri stays a declared dependency, so a normal `gem install` or `bundle
288
+ install` gets the fast path. Two things to know when loading the gem in
289
+ ruby.wasm yourself:
290
+
291
+ - Load `ruby_pptx`, `rubyzip` and `rexml`, but not `nokogiri`, which is
292
+ native. A loader that installs a gem together with its runtime
293
+ dependencies will stop at Nokogiri.
294
+ - Ship the whole `lib/` directory, not only its `.rb` files: the templates
295
+ in `lib/ruby_pptx/templates` (the default deck, notes pages, icons) are
296
+ read as files.
297
+
298
+ `tools/wasm/run.mjs` runs the gem this way under ruby.wasm's browser
299
+ filesystem, and CI uses it to build, save and reread a deck on every push.
300
+
216
301
  ## Development
217
302
 
218
303
  ```bash
@@ -258,8 +343,13 @@ git tag -a v0.1.0 -m "ruby_pptx 0.1.0" && git push origin v0.1.0
258
343
 
259
344
  `.github/workflows/release.yml` runs the full CI suite, builds the gem, installs
260
345
  it into an empty gem home to prove it loads, and creates a GitHub release with
261
- the gem attached and the changelog entry as its notes. It pushes to RubyGems
262
- only once a `RUBYGEMS_API_KEY` secret is set.
346
+ the gem attached and the changelog entry as its notes.
347
+
348
+ Publishing to RubyGems is a separate step: in the Actions tab, open **Publish to
349
+ RubyGems**, choose **Run workflow**, and pick the release's tag under "Use
350
+ workflow from". It refuses to run from a branch. RubyGems' `release-gem` action
351
+ builds the tagged commit and pushes it, authenticating by RubyGems trusted
352
+ publishing rather than a stored API key.
263
353
 
264
354
  ## License
265
355
 
@@ -33,7 +33,9 @@ module Pptx
33
33
  @hover = hover
34
34
  end
35
35
 
36
- def part = @parent.part
36
+ def part
37
+ @parent.part
38
+ end
37
39
 
38
40
  # @return [Pptx::Enum::PP_ACTION] NONE when nothing happens on click
39
41
  def action
@@ -78,7 +80,9 @@ module Pptx
78
80
  #
79
81
  # Unlike {#address} this does not report a slide partname for a jump: a
80
82
  # thing called a URL should be a URL.
81
- def url = action == Enum::PP_ACTION::HYPERLINK ? address : nil
83
+ def url
84
+ action == Enum::PP_ACTION::HYPERLINK ? address : nil
85
+ end
82
86
 
83
87
  # The slide this click jumps to, or nil.
84
88
  def target_slide
@@ -107,11 +111,15 @@ module Pptx
107
111
  self
108
112
  end
109
113
 
110
- def inspect = "#<Pptx::ActionSetting #{action.name} #{address.inspect}>"
114
+ def inspect
115
+ "#<Pptx::ActionSetting #{action.name} #{address.inspect}>"
116
+ end
111
117
 
112
118
  private
113
119
 
114
- def hlink = @element.find(@hover ? "a:hlinkHover" : "a:hlinkClick")
120
+ def hlink
121
+ @element.find(@hover ? "a:hlinkHover" : "a:hlinkClick")
122
+ end
115
123
 
116
124
  def get_or_add_hlink
117
125
  @hover ? @element.get_or_add_hlinkHover : @element.get_or_add_hlinkClick
@@ -330,8 +330,12 @@ module Pptx
330
330
  end
331
331
  end
332
332
 
333
- def basename(shape_type) = self.for(shape_type)[:basename]
333
+ def basename(shape_type)
334
+ self.for(shape_type)[:basename]
335
+ end
334
336
 
335
- def default_adjustments(shape_type) = self.for(shape_type)[:default_adjustments]
337
+ def default_adjustments(shape_type)
338
+ self.for(shape_type)[:default_adjustments]
339
+ end
336
340
  end
337
341
  end
@@ -223,6 +223,8 @@ module Pptx
223
223
  end
224
224
 
225
225
  # A colour may be given as an RGBColor or as a hex string.
226
- def rgb(value) = value.is_a?(RGBColor) ? value : RGBColor.from_string(value)
226
+ def rgb(value)
227
+ value.is_a?(RGBColor) ? value : RGBColor.from_string(value)
228
+ end
227
229
  end
228
230
  end
@@ -54,14 +54,22 @@ module Pptx
54
54
  ChartDataCategory.new(label, self).tap { |category| @categories << category }
55
55
  end
56
56
 
57
- def each(&) = @categories.each(&)
57
+ def each(&)
58
+ @categories.each(&)
59
+ end
58
60
 
59
- def [](index) = @categories[index]
61
+ def [](index)
62
+ @categories[index]
63
+ end
60
64
 
61
- def size = @categories.size
65
+ def size
66
+ @categories.size
67
+ end
62
68
  alias length size
63
69
 
64
- def empty? = @categories.empty?
70
+ def empty?
71
+ @categories.empty?
72
+ end
65
73
 
66
74
  # Levels of labels: 0 with no categories, 1 for a plain list.
67
75
  #
@@ -76,7 +84,9 @@ module Pptx
76
84
  end
77
85
 
78
86
  # The number of categories actually plotted.
79
- def leaf_count = @categories.sum(&:leaf_count)
87
+ def leaf_count
88
+ @categories.sum(&:leaf_count)
89
+ end
80
90
 
81
91
  # Each level as [index, label] pairs, leaf level first. The index is the
82
92
  # leaf position where that label's run begins.
@@ -85,11 +95,17 @@ module Pptx
85
95
  end
86
96
 
87
97
  # The leaf labels in plotting order.
88
- def leaf_labels = levels.first.to_a.map(&:last)
98
+ def leaf_labels
99
+ levels.first.to_a.map(&:last)
100
+ end
89
101
 
90
- def dates? = depth == 1 && date?(first.label)
102
+ def dates?
103
+ depth == 1 && date?(first.label)
104
+ end
91
105
 
92
- def numeric? = depth == 1 && (first.label.is_a?(Numeric) || date?(first.label))
106
+ def numeric?
107
+ depth == 1 && (first.label.is_a?(Numeric) || date?(first.label))
108
+ end
93
109
 
94
110
  # The number format for the categories: as set, or a date format for
95
111
  # dates, or "General".
@@ -111,7 +127,9 @@ module Pptx
111
127
  raise Error, "category not in these categories"
112
128
  end
113
129
 
114
- def inspect = "#<Pptx::ChartDataCategories depth=#{depth} #{leaf_labels.inspect}>"
130
+ def inspect
131
+ "#<Pptx::ChartDataCategories depth=#{depth} #{leaf_labels.inspect}>"
132
+ end
115
133
 
116
134
  private
117
135
 
@@ -121,7 +139,9 @@ module Pptx
121
139
  lower + [categories.map { |category| [category.idx, category.label] }]
122
140
  end
123
141
 
124
- def date?(value) = value.is_a?(Date) || value.is_a?(Time)
142
+ def date?(value)
143
+ value.is_a?(Date) || value.is_a?(Time)
144
+ end
125
145
  end
126
146
 
127
147
  # One category, or a group of them when it has sub-categories.
@@ -135,7 +155,9 @@ module Pptx
135
155
  end
136
156
 
137
157
  # The label; "" for a category given as nil.
138
- def label = @label.nil? ? "" : @label
158
+ def label
159
+ @label.nil? ? "" : @label
160
+ end
139
161
 
140
162
  # @return [ChartDataCategory] the new sub-category
141
163
  def add_sub_category(label)
@@ -161,10 +183,14 @@ module Pptx
161
183
  depths.first + 1
162
184
  end
163
185
 
164
- def leaf_count = @sub_categories.empty? ? 1 : @sub_categories.sum(&:leaf_count)
186
+ def leaf_count
187
+ @sub_categories.empty? ? 1 : @sub_categories.sum(&:leaf_count)
188
+ end
165
189
 
166
190
  # The leaf position at which this category's run begins.
167
- def idx = @parent.index_of(self)
191
+ def idx
192
+ @parent.index_of(self)
193
+ end
168
194
 
169
195
  # @api private
170
196
  def index_of(sub_category)
@@ -190,9 +216,13 @@ module Pptx
190
216
  end
191
217
 
192
218
  # The label as it appears in the category cache and worksheet.
193
- def to_s = label.to_s
219
+ def to_s
220
+ label.to_s
221
+ end
194
222
 
195
- def inspect = "#<Pptx::ChartDataCategory #{label.inspect}>"
223
+ def inspect
224
+ "#<Pptx::ChartDataCategory #{label.inspect}>"
225
+ end
196
226
 
197
227
  private
198
228