rubyXL 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. data/VERSION +1 -1
  2. data/lib/rubyXL.rb +1 -0
  3. data/lib/rubyXL/objects/border.rb +3 -4
  4. data/lib/rubyXL/objects/calculation_chain.rb +1 -1
  5. data/lib/rubyXL/objects/cell_style.rb +3 -4
  6. data/lib/rubyXL/objects/chartsheet.rb +78 -0
  7. data/lib/rubyXL/objects/container_nodes.rb +2 -3
  8. data/lib/rubyXL/objects/data_validation.rb +5 -10
  9. data/lib/rubyXL/objects/document_properties.rb +1 -1
  10. data/lib/rubyXL/objects/fill.rb +3 -6
  11. data/lib/rubyXL/objects/filters.rb +120 -0
  12. data/lib/rubyXL/objects/formula.rb +2 -2
  13. data/lib/rubyXL/objects/ooxml_object.rb +116 -56
  14. data/lib/rubyXL/objects/relationships.rb +5 -1
  15. data/lib/rubyXL/objects/shared_strings.rb +1 -1
  16. data/lib/rubyXL/objects/sheet_common.rb +50 -0
  17. data/lib/rubyXL/objects/sheet_data.rb +6 -1
  18. data/lib/rubyXL/objects/simple_types.rb +78 -0
  19. data/lib/rubyXL/objects/stylesheet.rb +15 -3
  20. data/lib/rubyXL/objects/text.rb +4 -5
  21. data/lib/rubyXL/objects/workbook.rb +151 -26
  22. data/lib/rubyXL/objects/worksheet.rb +329 -107
  23. data/lib/rubyXL/parser.rb +12 -11
  24. data/lib/rubyXL/workbook.rb +3 -2
  25. data/rdoc/README_rdoc.html +404 -0
  26. data/rdoc/RubyXL.html +337 -0
  27. data/rdoc/RubyXL/AExtensionStorageArea.html +105 -0
  28. data/rdoc/RubyXL/Alignment.html +108 -0
  29. data/rdoc/RubyXL/AlternateContent.html +105 -0
  30. data/rdoc/RubyXL/AutoFilter.html +105 -0
  31. data/rdoc/RubyXL/AutoFilterColumn.html +105 -0
  32. data/rdoc/RubyXL/BooleanNode.html +105 -0
  33. data/rdoc/RubyXL/BooleanValue.html +105 -0
  34. data/rdoc/RubyXL/Border.html +105 -0
  35. data/rdoc/RubyXL/BorderContainer.html +105 -0
  36. data/rdoc/RubyXL/BorderEdge.html +156 -0
  37. data/rdoc/RubyXL/Break.html +105 -0
  38. data/rdoc/RubyXL/BreakList.html +105 -0
  39. data/rdoc/RubyXL/CalculationChain.html +159 -0
  40. data/rdoc/RubyXL/CalculationChainCell.html +108 -0
  41. data/rdoc/RubyXL/CalculationProperties.html +105 -0
  42. data/rdoc/RubyXL/Cell.html +428 -0
  43. data/rdoc/RubyXL/CellSmartTag.html +105 -0
  44. data/rdoc/RubyXL/CellSmartTagContainer.html +105 -0
  45. data/rdoc/RubyXL/CellSmartTagProperty.html +105 -0
  46. data/rdoc/RubyXL/CellStyle.html +108 -0
  47. data/rdoc/RubyXL/CellStyleContainer.html +105 -0
  48. data/rdoc/RubyXL/CellStyleXFContainer.html +105 -0
  49. data/rdoc/RubyXL/CellValue.html +108 -0
  50. data/rdoc/RubyXL/CellWatch.html +105 -0
  51. data/rdoc/RubyXL/CellWatchContainer.html +105 -0
  52. data/rdoc/RubyXL/CellXFContainer.html +105 -0
  53. data/rdoc/RubyXL/Chartsheet.html +105 -0
  54. data/rdoc/RubyXL/ChartsheetPageSetup.html +105 -0
  55. data/rdoc/RubyXL/ChartsheetProperties.html +108 -0
  56. data/rdoc/RubyXL/ChartsheetProtection.html +108 -0
  57. data/rdoc/RubyXL/ChartsheetView.html +105 -0
  58. data/rdoc/RubyXL/ChartsheetViewContainer.html +105 -0
  59. data/rdoc/RubyXL/Color.html +163 -0
  60. data/rdoc/RubyXL/ColorFilter.html +105 -0
  61. data/rdoc/RubyXL/ColorScale.html +105 -0
  62. data/rdoc/RubyXL/ColorScheme.html +105 -0
  63. data/rdoc/RubyXL/ColorSet.html +105 -0
  64. data/rdoc/RubyXL/Colors.html +105 -0
  65. data/rdoc/RubyXL/ColumnRange.html +233 -0
  66. data/rdoc/RubyXL/ColumnRanges.html +275 -0
  67. data/rdoc/RubyXL/ConditionalFormatValue.html +105 -0
  68. data/rdoc/RubyXL/ConditionalFormatting.html +105 -0
  69. data/rdoc/RubyXL/ConditionalFormattingRule.html +105 -0
  70. data/rdoc/RubyXL/CustomFilter.html +105 -0
  71. data/rdoc/RubyXL/CustomFilterContainer.html +105 -0
  72. data/rdoc/RubyXL/CustomProperty.html +105 -0
  73. data/rdoc/RubyXL/CustomPropertyContainer.html +105 -0
  74. data/rdoc/RubyXL/CustomSheetView.html +105 -0
  75. data/rdoc/RubyXL/CustomSheetViews.html +105 -0
  76. data/rdoc/RubyXL/CustomWorkbookView.html +105 -0
  77. data/rdoc/RubyXL/CustomWorkbookViewContainer.html +105 -0
  78. data/rdoc/RubyXL/DXF.html +105 -0
  79. data/rdoc/RubyXL/DXFs.html +105 -0
  80. data/rdoc/RubyXL/DataBar.html +105 -0
  81. data/rdoc/RubyXL/DataConsolidate.html +105 -0
  82. data/rdoc/RubyXL/DataConsolidationReference.html +105 -0
  83. data/rdoc/RubyXL/DataConsolidationReferences.html +105 -0
  84. data/rdoc/RubyXL/DataValidation.html +108 -0
  85. data/rdoc/RubyXL/DataValidations.html +105 -0
  86. data/rdoc/RubyXL/DateGroupItem.html +108 -0
  87. data/rdoc/RubyXL/DefinedName.html +105 -0
  88. data/rdoc/RubyXL/DefinedNames.html +105 -0
  89. data/rdoc/RubyXL/DocumentProperties.html +271 -0
  90. data/rdoc/RubyXL/DynamicFilter.html +105 -0
  91. data/rdoc/RubyXL/EmbeddedControl.html +105 -0
  92. data/rdoc/RubyXL/EmbeddedControlContainer.html +105 -0
  93. data/rdoc/RubyXL/Extension.html +228 -0
  94. data/rdoc/RubyXL/ExtensionStorageArea.html +108 -0
  95. data/rdoc/RubyXL/ExternalReference.html +105 -0
  96. data/rdoc/RubyXL/ExternalReferences.html +105 -0
  97. data/rdoc/RubyXL/FieldItem.html +105 -0
  98. data/rdoc/RubyXL/FileRecoveryProperties.html +105 -0
  99. data/rdoc/RubyXL/FileSharing.html +108 -0
  100. data/rdoc/RubyXL/FileVersion.html +108 -0
  101. data/rdoc/RubyXL/Fill.html +105 -0
  102. data/rdoc/RubyXL/FillContainer.html +105 -0
  103. data/rdoc/RubyXL/FilterContainer.html +105 -0
  104. data/rdoc/RubyXL/FloatNode.html +105 -0
  105. data/rdoc/RubyXL/FloatValue.html +105 -0
  106. data/rdoc/RubyXL/Font.html +655 -0
  107. data/rdoc/RubyXL/FontContainer.html +105 -0
  108. data/rdoc/RubyXL/FontScheme.html +105 -0
  109. data/rdoc/RubyXL/FormatScheme.html +105 -0
  110. data/rdoc/RubyXL/Formula.html +108 -0
  111. data/rdoc/RubyXL/FunctionGroup.html +105 -0
  112. data/rdoc/RubyXL/FunctionGroupContainer.html +105 -0
  113. data/rdoc/RubyXL/GenericStorage.html +344 -0
  114. data/rdoc/RubyXL/GradientFill.html +105 -0
  115. data/rdoc/RubyXL/HeaderFooterSettings.html +105 -0
  116. data/rdoc/RubyXL/Hyperlink.html +105 -0
  117. data/rdoc/RubyXL/HyperlinkContainer.html +105 -0
  118. data/rdoc/RubyXL/IconFilter.html +105 -0
  119. data/rdoc/RubyXL/IconSet.html +105 -0
  120. data/rdoc/RubyXL/IgnoredError.html +105 -0
  121. data/rdoc/RubyXL/IgnoredErrorContainer.html +105 -0
  122. data/rdoc/RubyXL/IndexedColorContainer.html +105 -0
  123. data/rdoc/RubyXL/InputCells.html +105 -0
  124. data/rdoc/RubyXL/IntegerNode.html +105 -0
  125. data/rdoc/RubyXL/IntegerValue.html +105 -0
  126. data/rdoc/RubyXL/LegacyCell.html +1498 -0
  127. data/rdoc/RubyXL/LegacyWorkbook.html +1283 -0
  128. data/rdoc/RubyXL/LegacyWorksheet.html +3291 -0
  129. data/rdoc/RubyXL/MRUColorContainer.html +105 -0
  130. data/rdoc/RubyXL/MergedCell.html +105 -0
  131. data/rdoc/RubyXL/MergedCells.html +105 -0
  132. data/rdoc/RubyXL/NumFmt.html +105 -0
  133. data/rdoc/RubyXL/NumberFormat.html +160 -0
  134. data/rdoc/RubyXL/NumberFormatContainer.html +173 -0
  135. data/rdoc/RubyXL/OLEObject.html +105 -0
  136. data/rdoc/RubyXL/OLEObjects.html +105 -0
  137. data/rdoc/RubyXL/OLESize.html +105 -0
  138. data/rdoc/RubyXL/OOXMLObject.html +862 -0
  139. data/rdoc/RubyXL/OOXMLTopLevelObject.html +105 -0
  140. data/rdoc/RubyXL/OutlineProperties.html +108 -0
  141. data/rdoc/RubyXL/PageMargins.html +105 -0
  142. data/rdoc/RubyXL/PageSetup.html +105 -0
  143. data/rdoc/RubyXL/PageSetupProperties.html +108 -0
  144. data/rdoc/RubyXL/Pane.html +105 -0
  145. data/rdoc/RubyXL/Parser.html +348 -0
  146. data/rdoc/RubyXL/PatternFill.html +105 -0
  147. data/rdoc/RubyXL/PhoneticProperties.html +105 -0
  148. data/rdoc/RubyXL/PhoneticRun.html +105 -0
  149. data/rdoc/RubyXL/PivotArea.html +105 -0
  150. data/rdoc/RubyXL/PivotCache.html +105 -0
  151. data/rdoc/RubyXL/PivotCaches.html +105 -0
  152. data/rdoc/RubyXL/PivotReference.html +105 -0
  153. data/rdoc/RubyXL/PivotReferenceContainer.html +105 -0
  154. data/rdoc/RubyXL/PivotTableSelection.html +105 -0
  155. data/rdoc/RubyXL/PrintOptions.html +105 -0
  156. data/rdoc/RubyXL/ProtectedRange.html +105 -0
  157. data/rdoc/RubyXL/ProtectedRanges.html +105 -0
  158. data/rdoc/RubyXL/Protection.html +105 -0
  159. data/rdoc/RubyXL/RID.html +105 -0
  160. data/rdoc/RubyXL/RawOOXML.html +225 -0
  161. data/rdoc/RubyXL/Reference.html +642 -0
  162. data/rdoc/RubyXL/Relationship.html +105 -0
  163. data/rdoc/RubyXL/RichText.html +105 -0
  164. data/rdoc/RubyXL/RichTextRun.html +105 -0
  165. data/rdoc/RubyXL/Row.html +105 -0
  166. data/rdoc/RubyXL/RunProperties.html +108 -0
  167. data/rdoc/RubyXL/Scenario.html +105 -0
  168. data/rdoc/RubyXL/ScenarioContainer.html +105 -0
  169. data/rdoc/RubyXL/Selection.html +105 -0
  170. data/rdoc/RubyXL/SharedStringsTable.html +397 -0
  171. data/rdoc/RubyXL/Sheet.html +105 -0
  172. data/rdoc/RubyXL/SheetCalculationProperties.html +105 -0
  173. data/rdoc/RubyXL/SheetData.html +105 -0
  174. data/rdoc/RubyXL/Sheets.html +105 -0
  175. data/rdoc/RubyXL/SmartTagContainer.html +105 -0
  176. data/rdoc/RubyXL/SmartTagProperties.html +105 -0
  177. data/rdoc/RubyXL/SmartTagType.html +105 -0
  178. data/rdoc/RubyXL/SmartTagTypeContainer.html +105 -0
  179. data/rdoc/RubyXL/SortCondition.html +105 -0
  180. data/rdoc/RubyXL/SortState.html +105 -0
  181. data/rdoc/RubyXL/Sqref.html +199 -0
  182. data/rdoc/RubyXL/Stop.html +108 -0
  183. data/rdoc/RubyXL/StringNode.html +105 -0
  184. data/rdoc/RubyXL/StringValue.html +105 -0
  185. data/rdoc/RubyXL/Stylesheet.html +105 -0
  186. data/rdoc/RubyXL/TableParts.html +105 -0
  187. data/rdoc/RubyXL/TableStyle.html +105 -0
  188. data/rdoc/RubyXL/TableStyles.html +105 -0
  189. data/rdoc/RubyXL/Text.html +195 -0
  190. data/rdoc/RubyXL/Theme.html +105 -0
  191. data/rdoc/RubyXL/ThemeElements.html +105 -0
  192. data/rdoc/RubyXL/Top10.html +105 -0
  193. data/rdoc/RubyXL/Variant.html +108 -0
  194. data/rdoc/RubyXL/Vector.html +105 -0
  195. data/rdoc/RubyXL/VectorValue.html +105 -0
  196. data/rdoc/RubyXL/WebPublishObject.html +105 -0
  197. data/rdoc/RubyXL/WebPublishObjectContainer.html +105 -0
  198. data/rdoc/RubyXL/WebPublishingItem.html +108 -0
  199. data/rdoc/RubyXL/WebPublishingItemContainer.html +105 -0
  200. data/rdoc/RubyXL/WebPublishingProperties.html +105 -0
  201. data/rdoc/RubyXL/Workbook.html +105 -0
  202. data/rdoc/RubyXL/WorkbookProperties.html +108 -0
  203. data/rdoc/RubyXL/WorkbookProtection.html +105 -0
  204. data/rdoc/RubyXL/WorkbookRelationships.html +316 -0
  205. data/rdoc/RubyXL/WorkbookView.html +105 -0
  206. data/rdoc/RubyXL/WorkbookViews.html +105 -0
  207. data/rdoc/RubyXL/Worksheet.html +105 -0
  208. data/rdoc/RubyXL/WorksheetDimensions.html +105 -0
  209. data/rdoc/RubyXL/WorksheetFormatProperties.html +105 -0
  210. data/rdoc/RubyXL/WorksheetProperties.html +108 -0
  211. data/rdoc/RubyXL/WorksheetProtection.html +105 -0
  212. data/rdoc/RubyXL/WorksheetView.html +105 -0
  213. data/rdoc/RubyXL/WorksheetViews.html +105 -0
  214. data/rdoc/RubyXL/Writer.html +98 -0
  215. data/rdoc/RubyXL/Writer/ContentTypesWriter.html +289 -0
  216. data/rdoc/RubyXL/Writer/CoreWriter.html +210 -0
  217. data/rdoc/RubyXL/Writer/GenericWriter.html +348 -0
  218. data/rdoc/RubyXL/Writer/RootRelsWriter.html +193 -0
  219. data/rdoc/RubyXL/Writer/StylesWriter.html +191 -0
  220. data/rdoc/RubyXL/Writer/ThemeWriter.html +511 -0
  221. data/rdoc/RubyXL/Writer/WorkbookWriter.html +249 -0
  222. data/rdoc/RubyXL/Writer/WorksheetWriter.html +236 -0
  223. data/rdoc/RubyXL/XF.html +105 -0
  224. data/rdoc/created.rid +24 -21
  225. data/rdoc/index.html +216 -0
  226. data/rdoc/js/search_index.js +1 -1
  227. data/rdoc/table_of_contents.html +1496 -0
  228. data/rubyXL.gemspec +211 -4
  229. data/spec/lib/parser_spec.rb +18 -6
  230. data/test/input/.gitkeep +0 -0
  231. data/test/output/.gitkeep +0 -0
  232. data/test/test_parse_write.rb +15 -0
  233. metadata +211 -4
  234. data/lib/rubyXL/objects/sheet_view.rb +0 -71
@@ -0,0 +1,862 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class RubyXL::OOXMLObject - rubyXL 2.1.3</title>
8
+
9
+ <link href="../fonts.css" rel="stylesheet">
10
+ <link href="../rdoc.css" rel="stylesheet">
11
+
12
+ <script type="text/javascript">
13
+ var rdoc_rel_prefix = "../";
14
+ </script>
15
+
16
+ <script src="../js/jquery.js"></script>
17
+ <script src="../js/navigation.js"></script>
18
+ <script src="../js/search_index.js"></script>
19
+ <script src="../js/search.js"></script>
20
+ <script src="../js/searcher.js"></script>
21
+ <script src="../js/darkfish.js"></script>
22
+
23
+
24
+ <body id="top" role="document" class="class">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="../index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="../table_of_contents.html#pages">Pages</a>
34
+ <a href="../table_of_contents.html#classes">Classes</a>
35
+ <a href="../table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+
60
+ <div id="parent-class-section" class="nav-section">
61
+ <h3>Parent</h3>
62
+
63
+
64
+ <p class="link">Object
65
+
66
+ </div>
67
+
68
+
69
+
70
+ <!-- Method Quickref -->
71
+ <div id="method-list-section" class="nav-section">
72
+ <h3>Methods</h3>
73
+
74
+ <ul class="link-list" role="directory">
75
+
76
+ <li ><a href="#method-c-define_attribute">::define_attribute</a>
77
+
78
+ <li ><a href="#method-c-define_child_node">::define_child_node</a>
79
+
80
+ <li ><a href="#method-c-define_element_name">::define_element_name</a>
81
+
82
+ <li ><a href="#method-c-new">::new</a>
83
+
84
+ <li ><a href="#method-c-obtain_class_variable">::obtain_class_variable</a>
85
+
86
+ <li ><a href="#method-c-parse">::parse</a>
87
+
88
+ <li ><a href="#method-c-set_countable">::set_countable</a>
89
+
90
+ <li ><a href="#method-i-before_write_xml">#before_write_xml</a>
91
+
92
+ <li class="calls-super" ><a href="#method-i-dup">#dup</a>
93
+
94
+ <li ><a href="#method-i-index_in_collection">#index_in_collection</a>
95
+
96
+ <li ><a href="#method-i-write_xml">#write_xml</a>
97
+
98
+ </ul>
99
+ </div>
100
+
101
+ </div>
102
+ </nav>
103
+
104
+ <main role="main" aria-labelledby="class-RubyXL::OOXMLObject">
105
+ <h1 id="class-RubyXL::OOXMLObject" class="class">
106
+ class RubyXL::OOXMLObject
107
+ </h1>
108
+
109
+ <section class="description">
110
+
111
+ <p>Parent class for defining OOXML based objects (not unlike Rails’
112
+ <code>ActiveRecord</code>!) Most importantly, provides functionality of
113
+ parsing such objects from XML, and marshalling them to XML.</p>
114
+
115
+ </section>
116
+
117
+
118
+
119
+
120
+ <section id="5Buntitled-5D" class="documentation-section">
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
131
+ <header>
132
+ <h3>Public Class Methods</h3>
133
+ </header>
134
+
135
+
136
+ <div id="method-c-define_attribute" class="method-detail ">
137
+
138
+ <div class="method-heading">
139
+ <span class="method-name">define_attribute</span><span
140
+ class="method-args">(attr_name, attr_type, extra_params = {})</span>
141
+
142
+ <span class="method-click-advice">click to toggle source</span>
143
+
144
+ </div>
145
+
146
+
147
+ <div class="method-description">
148
+
149
+ <p>Defines an attribute of OOXML object.</p>
150
+
151
+ <h3 id="method-c-define_attribute-label-Parameters">Parameters<span><a href="#method-c-define_attribute-label-Parameters">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
152
+ <ul><li>
153
+ <p><code>attribute_name</code> - Name of the element attribute as seen in the
154
+ source XML. Can be either <code>&quot;String&quot;</code> or
155
+ <code>:Symbol</code></p>
156
+ <ul><li>
157
+ <p>Special attibute name <code>'_'</code> (underscore) denotes the value of
158
+ the element rather than attribute.</p>
159
+ </li></ul>
160
+ </li><li>
161
+ <p><code>attribute_type</code> - Specifies the conversion type for the
162
+ attribute when parsing. Available options are:</p>
163
+ <ul><li>
164
+ <p><code>:int</code> - <code>Integer</code></p>
165
+ </li><li>
166
+ <p><code>:float</code> - <code>Float</code></p>
167
+ </li><li>
168
+ <p><code>:string</code> - <code>String</code> (no conversion)</p>
169
+ </li><li>
170
+ <p><code>:sqref</code> - <a href="Sqref.html">RubyXL::Sqref</a></p>
171
+ </li><li>
172
+ <p><code>:ref</code> - <a href="Reference.html">RubyXL::Reference</a></p>
173
+ </li><li>
174
+ <p><code>:bool</code> - <code>Boolean</code> ("1" and "true" convert to
175
+ <code>true</code>, others to <code>false</code>)</p>
176
+ </li><li>
177
+ <p>one of <code>simple_types</code> - <code>String</code>, plus the list of
178
+ acceptable values is saved for future validation (not used yet).</p>
179
+ </li></ul>
180
+ </li><li>
181
+ <p><code>extra_parameters</code> - Hash of optional parameters as follows:</p>
182
+ <ul><li>
183
+ <p><code>:accessor</code> - Name of the accessor for this attribute to be
184
+ defined on the object. If not provided, defaults to classidied
185
+ <code>attribute_name</code>.</p>
186
+ </li><li>
187
+ <p><code>:default</code> - Value this attribute defaults to if not explicitly
188
+ provided.</p>
189
+ </li><li>
190
+ <p><code>:required</code> - Whether this attribute is required when writing
191
+ XML. If the value of the attrinute is not explicitly provided,
192
+ <code>:default</code> is written instead.</p>
193
+ </li></ul>
194
+ </li></ul>
195
+
196
+ <h4 id="method-c-define_attribute-label-Examples">Examples<span><a href="#method-c-define_attribute-label-Examples">&para;</a> <a href="#documentation">&uarr;</a></span></h4>
197
+
198
+ <pre class="ruby"><span class="ruby-identifier">define_attribute</span>(:<span class="ruby-identifier">outline</span>, :<span class="ruby-identifier">bool</span>, :<span class="ruby-identifier">default</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>)
199
+ </pre>
200
+
201
+ <p>A <code>Boolean</code> attribute ‘outline’ with default value
202
+ <code>true</code> will be accessible by calling <code>obj.outline</code></p>
203
+
204
+ <pre>define_attribute(:uniqueCount, :int)</pre>
205
+
206
+ <p>An <code>Integer</code> attribute ‘uniqueCount’ accessible as
207
+ <code>obj.unique_count</code></p>
208
+
209
+ <pre class="ruby"><span class="ruby-identifier">define_attribute</span>(:<span class="ruby-identifier">_</span>, :<span class="ruby-identifier">string</span>, :<span class="ruby-identifier">accessor</span> =<span class="ruby-operator">&gt;</span> :<span class="ruby-identifier">expression</span>)
210
+ </pre>
211
+
212
+ <p>The value of the element will be accessible as a <code>String</code> by
213
+ calling <code>obj.expression</code></p>
214
+
215
+ <pre class="ruby"><span class="ruby-identifier">define_attribute</span>(:<span class="ruby-identifier">errorStyle</span>, :<span class="ruby-identifier">string</span>, :<span class="ruby-identifier">default</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'stop'</span>, :<span class="ruby-identifier">values</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">%w{ stop warning information }</span>)
216
+ </pre>
217
+
218
+ <p>A <code>String</code> attribute named ‘errorStyle’ will be accessible as
219
+ <code>obj.error_style</code>, valid values are
220
+ <code>&quot;stop&quot;</code>, <code>&quot;warning&quot;</code>,
221
+ <code>&quot;information&quot;</code></p>
222
+
223
+
224
+
225
+
226
+ <div class="method-source-code" id="define_attribute-source">
227
+ <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 53</span>
228
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">define_attribute</span>(<span class="ruby-identifier">attr_name</span>, <span class="ruby-identifier">attr_type</span>, <span class="ruby-identifier">extra_params</span> = {})
229
+ <span class="ruby-identifier">attrs</span> = <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_attributes</span>)
230
+
231
+ <span class="ruby-identifier">accessor</span> = <span class="ruby-identifier">extra_params</span>[<span class="ruby-value">:accessor</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">accessorize</span>(<span class="ruby-identifier">attr_name</span>)
232
+ <span class="ruby-identifier">attr_name</span> = <span class="ruby-identifier">attr_name</span>.<span class="ruby-identifier">to_s</span>
233
+
234
+ <span class="ruby-identifier">attr_hash</span> = {
235
+ <span class="ruby-value">:accessor</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">accessor</span>,
236
+ <span class="ruby-value">:attr_type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">attr_type</span>,
237
+ <span class="ruby-value">:optional</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">extra_params</span>[<span class="ruby-value">:required</span>],
238
+ <span class="ruby-value">:default</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">extra_params</span>[<span class="ruby-value">:default</span>],
239
+ }
240
+
241
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">attr_type</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>) <span class="ruby-keyword">then</span>
242
+ <span class="ruby-identifier">attr_hash</span>[<span class="ruby-value">:values</span>] = <span class="ruby-identifier">attr_type</span>
243
+ <span class="ruby-identifier">attr_hash</span>[<span class="ruby-value">:attr_type</span>] = <span class="ruby-value">:string</span>
244
+ <span class="ruby-keyword">end</span>
245
+
246
+
247
+ <span class="ruby-identifier">attrs</span>[<span class="ruby-identifier">attr_name</span>] = <span class="ruby-identifier">attr_hash</span>
248
+
249
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:attr_accessor</span>, <span class="ruby-identifier">accessor</span>)
250
+ <span class="ruby-keyword">end</span></pre>
251
+ </div>
252
+
253
+ </div>
254
+
255
+
256
+
257
+
258
+ </div>
259
+
260
+
261
+ <div id="method-c-define_child_node" class="method-detail ">
262
+
263
+ <div class="method-heading">
264
+ <span class="method-name">define_child_node</span><span
265
+ class="method-args">(klass, extra_params = {})</span>
266
+
267
+ <span class="method-click-advice">click to toggle source</span>
268
+
269
+ </div>
270
+
271
+
272
+ <div class="method-description">
273
+
274
+ <p>Defines a child node of OOXML object.</p>
275
+
276
+ <h3 id="method-c-define_child_node-label-Parameters">Parameters<span><a href="#method-c-define_child_node-label-Parameters">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
277
+ <ul><li>
278
+ <p><code>klass</code> - Class (descendant of <a
279
+ href="OOXMLObject.html">RubyXL::OOXMLObject</a>) of the child nodes. Child
280
+ node objects will be produced by calling <code>parse</code> method of that
281
+ class.</p>
282
+ </li><li>
283
+ <p><code>extra_parameters</code> - Hash of optional parameters as follows:</p>
284
+ <ul><li>
285
+ <p><code>:accessor</code> - Name of the accessor for this attribute to be
286
+ defined on the object. If not provided, defaults to classidied
287
+ <code>attribute_name</code>.</p>
288
+ </li><li>
289
+ <p><code>:node_name</code> - Node name for the child node, in case it does not
290
+ match the one defined by the <code>klass</code>.</p>
291
+ </li><li>
292
+ <p><code>:collection</code> - Whether the child node should be treated as a
293
+ single node or a collection of nodes:</p>
294
+ <ul><li>
295
+ <p><code>false</code> (default) - child node is directly accessible through
296
+ the respective accessor;</p>
297
+ </li><li>
298
+ <p><code>true</code> - a collection of child nodes is accessed as
299
+ <code>Array</code> through the respective accessor;</p>
300
+ </li><li>
301
+ <p><code>:with_count</code> - same as <code>true</code>, but in addition, the
302
+ attribute <code>count</code> is defined on the current object, that will be
303
+ automatically set to the number of elements in the collection at the start
304
+ of <code>write_xml</code> call.</p>
305
+ </li></ul>
306
+ </li></ul>
307
+ </li></ul>
308
+
309
+ <h4 id="method-c-define_child_node-label-Examples">Examples<span><a href="#method-c-define_child_node-label-Examples">&para;</a> <a href="#documentation">&uarr;</a></span></h4>
310
+
311
+ <pre>define_child_node(RubyXL::Alignment)</pre>
312
+
313
+ <p>Define a singular child node parsed by the RubyXL::BorderEdge.parse() and
314
+ accessed by the default <code>obj.alignment</code> accessor</p>
315
+
316
+ <pre class="ruby"><span class="ruby-identifier">define_child_node</span>(<span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">Hyperlink</span>, :<span class="ruby-identifier">colection</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, :<span class="ruby-identifier">accessor</span> =<span class="ruby-operator">&gt;</span> :<span class="ruby-identifier">hyperlinks</span>)
317
+ </pre>
318
+
319
+ <p>Define an array of nodes accessed by <code>obj.hyperlinks</code> accessor,
320
+ each of which will be parsed by the <a
321
+ href="OOXMLObject.html#method-c-parse">::parse</a></p>
322
+
323
+ <pre class="ruby"><span class="ruby-identifier">define_child_node</span>(<span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">BorderEdge</span>, :<span class="ruby-identifier">node_name</span> =<span class="ruby-operator">&gt;</span> :<span class="ruby-identifier">left</span>)
324
+ <span class="ruby-identifier">define_child_node</span>(<span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">BorderEdge</span>, :<span class="ruby-identifier">node_name</span> =<span class="ruby-operator">&gt;</span> :<span class="ruby-identifier">right</span>)
325
+ </pre>
326
+
327
+ <p>Use class <a href="BorderEdge.html">RubyXL::BorderEdge</a> when parsing
328
+ both the elements <code>&lt;left ...&gt;</code> and <code>&lt;right
329
+ ...&gt;</code> elements.</p>
330
+
331
+ <pre class="ruby"><span class="ruby-identifier">define_child_node</span>(<span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">Font</span>, :<span class="ruby-identifier">collection</span> =<span class="ruby-operator">&gt;</span> :<span class="ruby-identifier">with_count</span>, :<span class="ruby-identifier">accessor</span> =<span class="ruby-operator">&gt;</span> :<span class="ruby-identifier">fonts</span>)
332
+ </pre>
333
+
334
+ <p>Upon writing of the object this was defined on, its <code>count</code>
335
+ attribute will be set to the count of nodes in <code>fonts</code> array</p>
336
+
337
+
338
+
339
+
340
+ <div class="method-source-code" id="define_child_node-source">
341
+ <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 97</span>
342
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">define_child_node</span>(<span class="ruby-identifier">klass</span>, <span class="ruby-identifier">extra_params</span> = {})
343
+ <span class="ruby-identifier">child_nodes</span> = <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_child_nodes</span>)
344
+ <span class="ruby-identifier">child_node_name</span> = (<span class="ruby-identifier">extra_params</span>[<span class="ruby-value">:node_name</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class_variable_get</span>(<span class="ruby-value">:@@ooxml_tag_name</span>)).<span class="ruby-identifier">to_s</span>
345
+ <span class="ruby-identifier">accessor</span> = (<span class="ruby-identifier">extra_params</span>[<span class="ruby-value">:accessor</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">accessorize</span>(<span class="ruby-identifier">child_node_name</span>)).<span class="ruby-identifier">to_sym</span>
346
+
347
+ <span class="ruby-identifier">child_nodes</span>[<span class="ruby-identifier">child_node_name</span>] = {
348
+ <span class="ruby-value">:class</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">klass</span>,
349
+ <span class="ruby-value">:is_array</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">extra_params</span>[<span class="ruby-value">:collection</span>],
350
+ <span class="ruby-value">:accessor</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">accessor</span>
351
+ }
352
+
353
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">extra_params</span>[<span class="ruby-value">:collection</span>] <span class="ruby-operator">==</span> <span class="ruby-value">:with_count</span> <span class="ruby-keyword">then</span>
354
+ <span class="ruby-identifier">define_attribute</span>(<span class="ruby-value">:count</span>, <span class="ruby-value">:int</span>, <span class="ruby-value">:required</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>)
355
+ <span class="ruby-keyword">end</span>
356
+
357
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:attr_accessor</span>, <span class="ruby-identifier">accessor</span>)
358
+ <span class="ruby-keyword">end</span></pre>
359
+ </div>
360
+
361
+ </div>
362
+
363
+
364
+
365
+
366
+ </div>
367
+
368
+
369
+ <div id="method-c-define_element_name" class="method-detail ">
370
+
371
+ <div class="method-heading">
372
+ <span class="method-name">define_element_name</span><span
373
+ class="method-args">(element_name)</span>
374
+
375
+ <span class="method-click-advice">click to toggle source</span>
376
+
377
+ </div>
378
+
379
+
380
+ <div class="method-description">
381
+
382
+ <p>Defines the name of the element that represents the current OOXML object.
383
+ Should only be used once per object. In case of different objects
384
+ represented by the same class in different parts of OOXML tree,
385
+ <code>:node_name</code> extra parameter can be used to override the
386
+ default element name.</p>
387
+
388
+ <h3 id="method-c-define_element_name-label-Parameters">Parameters<span><a href="#method-c-define_element_name-label-Parameters">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
389
+ <ul><li>
390
+ <p><code>element_name</code></p>
391
+ </li></ul>
392
+
393
+ <h4 id="method-c-define_element_name-label-Examples">Examples<span><a href="#method-c-define_element_name-label-Examples">&para;</a> <a href="#documentation">&uarr;</a></span></h4>
394
+
395
+ <pre>define_element_name 'externalReference'</pre>
396
+
397
+
398
+
399
+
400
+ <div class="method-source-code" id="define_element_name-source">
401
+ <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 122</span>
402
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">define_element_name</span>(<span class="ruby-identifier">element_name</span>)
403
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class_variable_set</span>(<span class="ruby-value">:@@ooxml_tag_name</span>, <span class="ruby-identifier">element_name</span>)
404
+ <span class="ruby-keyword">end</span></pre>
405
+ </div>
406
+
407
+ </div>
408
+
409
+
410
+
411
+
412
+ </div>
413
+
414
+
415
+ <div id="method-c-new" class="method-detail ">
416
+
417
+ <div class="method-heading">
418
+ <span class="method-name">new</span><span
419
+ class="method-args">(params = {})</span>
420
+
421
+ <span class="method-click-advice">click to toggle source</span>
422
+
423
+ </div>
424
+
425
+
426
+ <div class="method-description">
427
+
428
+
429
+
430
+
431
+
432
+
433
+ <div class="method-source-code" id="new-source">
434
+ <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 188</span>
435
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">params</span> = {})
436
+ <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_attributes</span>).<span class="ruby-identifier">each_value</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
437
+ <span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">&quot;@#{v[:accessor]}&quot;</span>, <span class="ruby-identifier">params</span>[<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>]])
438
+ }
439
+
440
+ <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_child_nodes</span>).<span class="ruby-identifier">each_value</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
441
+
442
+ <span class="ruby-identifier">initial_value</span> =
443
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>]) <span class="ruby-keyword">then</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>]]
444
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">:is_array</span>] <span class="ruby-keyword">then</span> []
445
+ <span class="ruby-keyword">else</span> <span class="ruby-keyword">nil</span>
446
+ <span class="ruby-keyword">end</span>
447
+
448
+ <span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">&quot;@#{v[:accessor]}&quot;</span>, <span class="ruby-identifier">initial_value</span>)
449
+ }
450
+
451
+ <span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-string">&quot;@count&quot;</span>, <span class="ruby-value">0</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_countable</span>, <span class="ruby-keyword">false</span>)
452
+ <span class="ruby-keyword">end</span></pre>
453
+ </div>
454
+
455
+ </div>
456
+
457
+
458
+
459
+
460
+ </div>
461
+
462
+
463
+ <div id="method-c-obtain_class_variable" class="method-detail ">
464
+
465
+ <div class="method-heading">
466
+ <span class="method-name">obtain_class_variable</span><span
467
+ class="method-args">(var_name, default = {})</span>
468
+
469
+ <span class="method-click-advice">click to toggle source</span>
470
+
471
+ </div>
472
+
473
+
474
+ <div class="method-description">
475
+
476
+ <p>Get the value of a [sub]class variable if it exists, or create the
477
+ respective variable with the passed-in <code>default</code> (or +{}+, if
478
+ not specified)</p>
479
+
480
+ <p>Throughout this class, we are setting class variables through explicit
481
+ method calls rather than by directly addressing the name of the variable
482
+ because of context issues: addressing variable by name creates it in the
483
+ context of defining class, while calling the setter/getter method addresses
484
+ it in the context of descendant class, which is what we need.</p>
485
+
486
+
487
+
488
+
489
+ <div class="method-source-code" id="obtain_class_variable-source">
490
+ <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 15</span>
491
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-identifier">var_name</span>, <span class="ruby-identifier">default</span> = {})
492
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">class_variable_defined?</span>(<span class="ruby-identifier">var_name</span>) <span class="ruby-keyword">then</span>
493
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class_variable_get</span>(<span class="ruby-identifier">var_name</span>)
494
+ <span class="ruby-keyword">else</span>
495
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class_variable_set</span>(<span class="ruby-identifier">var_name</span>, <span class="ruby-identifier">default</span>)
496
+ <span class="ruby-keyword">end</span>
497
+ <span class="ruby-keyword">end</span></pre>
498
+ </div>
499
+
500
+ </div>
501
+
502
+
503
+
504
+
505
+ </div>
506
+
507
+
508
+ <div id="method-c-parse" class="method-detail ">
509
+
510
+ <div class="method-heading">
511
+ <span class="method-name">parse</span><span
512
+ class="method-args">(node)</span>
513
+
514
+ <span class="method-click-advice">click to toggle source</span>
515
+
516
+ </div>
517
+
518
+
519
+ <div class="method-description">
520
+
521
+
522
+
523
+
524
+
525
+
526
+ <div class="method-source-code" id="parse-source">
527
+ <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 207</span>
528
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">node</span>)
529
+ <span class="ruby-identifier">node</span> = <span class="ruby-constant">Nokogiri</span><span class="ruby-operator">::</span><span class="ruby-constant">XML</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">node</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">IO</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
530
+
531
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">node</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Nokogiri</span><span class="ruby-operator">::</span><span class="ruby-constant">XML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>) <span class="ruby-keyword">then</span>
532
+ <span class="ruby-comment"># @namespaces = node.namespaces
533
+ <span class="ruby-identifier">node</span> = <span class="ruby-identifier">node</span>.<span class="ruby-identifier">root</span>
534
+ <span class="ruby-comment"># ignorable_attr = node.attributes['Ignorable']
535
+ <span class="ruby-comment"># @ignorables &lt;&lt; ignorable_attr.value if ignorable_attr
536
+ <span class="ruby-keyword">end</span>
537
+
538
+ <span class="ruby-identifier">obj</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">new</span>
539
+
540
+ <span class="ruby-identifier">known_attributes</span> = <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_attributes</span>)
541
+
542
+ <span class="ruby-identifier">content_params</span> = <span class="ruby-identifier">known_attributes</span>[<span class="ruby-string">'_'</span>]
543
+ <span class="ruby-identifier">process_attribute</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">node</span>.<span class="ruby-identifier">text</span>, <span class="ruby-identifier">content_params</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">content_params</span>
544
+
545
+ <span class="ruby-identifier">node</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">attr_name</span>, <span class="ruby-identifier">attr</span><span class="ruby-operator">|</span>
546
+ <span class="ruby-identifier">attr_name</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">namespace</span> <span class="ruby-keyword">then</span> <span class="ruby-node">&quot;#{attr.namespace.prefix}:#{attr.name}&quot;</span>
547
+ <span class="ruby-keyword">else</span> <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">name</span>
548
+ <span class="ruby-keyword">end</span>
549
+
550
+ <span class="ruby-identifier">attr_params</span> = <span class="ruby-identifier">known_attributes</span>[<span class="ruby-identifier">attr_name</span>]
551
+
552
+ <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">attr_params</span>.<span class="ruby-identifier">nil?</span>
553
+ <span class="ruby-comment"># raise &quot;Unknown attribute: #{attr_name}&quot; if attr_params.nil?
554
+ <span class="ruby-identifier">process_attribute</span>(<span class="ruby-identifier">obj</span>, <span class="ruby-identifier">attr</span>.<span class="ruby-identifier">value</span>, <span class="ruby-identifier">attr_params</span>)
555
+ }
556
+
557
+ <span class="ruby-identifier">known_child_nodes</span> = <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_child_nodes</span>)
558
+
559
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">known_child_nodes</span>.<span class="ruby-identifier">empty?</span>
560
+ <span class="ruby-identifier">node</span>.<span class="ruby-identifier">element_children</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">child_node</span><span class="ruby-operator">|</span>
561
+
562
+ <span class="ruby-identifier">child_node_name</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">child_node</span>.<span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">prefix</span> <span class="ruby-keyword">then</span>
563
+ <span class="ruby-node">&quot;#{child_node.namespace.prefix}:#{child_node.name}&quot;</span>
564
+ <span class="ruby-keyword">else</span> <span class="ruby-identifier">child_node</span>.<span class="ruby-identifier">name</span>
565
+ <span class="ruby-keyword">end</span>
566
+
567
+ <span class="ruby-identifier">child_node_params</span> = <span class="ruby-identifier">known_child_nodes</span>[<span class="ruby-identifier">child_node_name</span>]
568
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown child node: #{child_node_name}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">child_node_params</span>.<span class="ruby-identifier">nil?</span>
569
+ <span class="ruby-identifier">parsed_object</span> = <span class="ruby-identifier">child_node_params</span>[<span class="ruby-value">:class</span>].<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">child_node</span>)
570
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">child_node_params</span>[<span class="ruby-value">:is_array</span>] <span class="ruby-keyword">then</span>
571
+ <span class="ruby-identifier">index</span> = <span class="ruby-identifier">parsed_object</span>.<span class="ruby-identifier">index_in_collection</span>
572
+ <span class="ruby-identifier">collection</span> = <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">child_node_params</span>[<span class="ruby-value">:accessor</span>])
573
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">index</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">then</span>
574
+ <span class="ruby-identifier">collection</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">parsed_object</span>
575
+ <span class="ruby-keyword">else</span>
576
+ <span class="ruby-identifier">collection</span>[<span class="ruby-identifier">index</span>] = <span class="ruby-identifier">parsed_object</span>
577
+ <span class="ruby-keyword">end</span>
578
+ <span class="ruby-keyword">else</span>
579
+ <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{child_node_params[:accessor]}=&quot;</span>, <span class="ruby-identifier">parsed_object</span>)
580
+ <span class="ruby-keyword">end</span>
581
+ }
582
+ <span class="ruby-keyword">end</span>
583
+
584
+ <span class="ruby-identifier">obj</span>
585
+ <span class="ruby-keyword">end</span></pre>
586
+ </div>
587
+
588
+ </div>
589
+
590
+
591
+
592
+
593
+ </div>
594
+
595
+
596
+ <div id="method-c-set_countable" class="method-detail ">
597
+
598
+ <div class="method-heading">
599
+ <span class="method-name">set_countable</span><span
600
+ class="method-args">()</span>
601
+
602
+ <span class="method-click-advice">click to toggle source</span>
603
+
604
+ </div>
605
+
606
+
607
+ <div class="method-description">
608
+
609
+ <p>TODO# This method will eventually be obsoleted.</p>
610
+
611
+
612
+
613
+
614
+ <div class="method-source-code" id="set_countable-source">
615
+ <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 127</span>
616
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">set_countable</span>
617
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class_variable_set</span>(<span class="ruby-value">:@@ooxml_countable</span>, <span class="ruby-keyword">true</span>)
618
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:attr_accessor</span>, <span class="ruby-value">:count</span>)
619
+ <span class="ruby-keyword">end</span></pre>
620
+ </div>
621
+
622
+ </div>
623
+
624
+
625
+
626
+
627
+ </div>
628
+
629
+
630
+ </section>
631
+
632
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
633
+ <header>
634
+ <h3>Public Instance Methods</h3>
635
+ </header>
636
+
637
+
638
+ <div id="method-i-before_write_xml" class="method-detail ">
639
+
640
+ <div class="method-heading">
641
+ <span class="method-name">before_write_xml</span><span
642
+ class="method-args">()</span>
643
+
644
+ <span class="method-click-advice">click to toggle source</span>
645
+
646
+ </div>
647
+
648
+
649
+ <div class="method-description">
650
+
651
+ <p>Subclass provided filter to perform last-minute operations (cleanup, count,
652
+ etc.) immediately prior to write, along with option to terminate the actual
653
+ write if <code>false</code> is returned (for example, to avoid writing the
654
+ collection’s root node if the collection is empty).</p>
655
+
656
+
657
+
658
+
659
+ <div class="method-source-code" id="before_write_xml-source">
660
+ <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 282</span>
661
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">before_write_xml</span>
662
+ <span class="ruby-identifier">child_nodes</span> = <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_child_nodes</span>)
663
+ <span class="ruby-identifier">child_nodes</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">child_node_name</span>, <span class="ruby-identifier">child_node_params</span><span class="ruby-operator">|</span>
664
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">count</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">child_node_params</span>[<span class="ruby-value">:accessor</span>]).<span class="ruby-identifier">size</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">child_node_params</span>[<span class="ruby-value">:is_array</span>] <span class="ruby-operator">==</span> <span class="ruby-value">:with_count</span>
665
+ }
666
+ <span class="ruby-keyword">true</span>
667
+ <span class="ruby-keyword">end</span></pre>
668
+ </div>
669
+
670
+ </div>
671
+
672
+
673
+
674
+
675
+ </div>
676
+
677
+
678
+ <div id="method-i-dup" class="method-detail ">
679
+
680
+ <div class="method-heading">
681
+ <span class="method-name">dup</span><span
682
+ class="method-args">()</span>
683
+
684
+ <span class="method-click-advice">click to toggle source</span>
685
+
686
+ </div>
687
+
688
+
689
+ <div class="method-description">
690
+
691
+
692
+
693
+
694
+ <div class="method-calls-super">
695
+ Calls superclass method
696
+
697
+ </div>
698
+
699
+
700
+
701
+ <div class="method-source-code" id="dup-source">
702
+ <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 266</span>
703
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">dup</span>
704
+ <span class="ruby-identifier">new_copy</span> = <span class="ruby-keyword">super</span>
705
+ <span class="ruby-identifier">new_copy</span>.<span class="ruby-identifier">count</span> = <span class="ruby-value">0</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_countable</span>, <span class="ruby-keyword">false</span>)
706
+ <span class="ruby-identifier">new_copy</span>
707
+ <span class="ruby-keyword">end</span></pre>
708
+ </div>
709
+
710
+ </div>
711
+
712
+
713
+
714
+
715
+ </div>
716
+
717
+
718
+ <div id="method-i-index_in_collection" class="method-detail ">
719
+
720
+ <div class="method-heading">
721
+ <span class="method-name">index_in_collection</span><span
722
+ class="method-args">()</span>
723
+
724
+ <span class="method-click-advice">click to toggle source</span>
725
+
726
+ </div>
727
+
728
+
729
+ <div class="method-description">
730
+
731
+ <p>Prototype method. For sparse collections (<code>Rows</code>,
732
+ <code>Cells</code>, etc.) must return index at which this object is
733
+ expected to reside in the collection. If <code>nil</code> is returned, then
734
+ object is simply added to the end of the collection.</p>
735
+
736
+
737
+
738
+
739
+ <div class="method-source-code" id="index_in_collection-source">
740
+ <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 275</span>
741
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">index_in_collection</span>
742
+ <span class="ruby-keyword">nil</span>
743
+ <span class="ruby-keyword">end</span></pre>
744
+ </div>
745
+
746
+ </div>
747
+
748
+
749
+
750
+
751
+ </div>
752
+
753
+
754
+ <div id="method-i-write_xml" class="method-detail ">
755
+
756
+ <div class="method-heading">
757
+ <span class="method-name">write_xml</span><span
758
+ class="method-args">(xml = nil, node_name_override = nil)</span>
759
+
760
+ <span class="method-click-advice">click to toggle source</span>
761
+
762
+ </div>
763
+
764
+
765
+ <div class="method-description">
766
+
767
+ <p>Recursively write the OOXML object and all its children out as
768
+ Nokogiri::XML. Immediately before the actual generation,
769
+ +before_write_xml()+ is called to perform last-minute cleanup and
770
+ validation operations; if it returns <code>false</code>, an empty string is
771
+ returned (rather than <code>nil</code>, so Nokogiri::XML’s
772
+ <code>&amp;lt;&amp;lt;</code> operator can be used without additional
773
+ <code>nil</code> checking)</p>
774
+
775
+ <h3 id="method-i-write_xml-label-Parameters">Parameters<span><a href="#method-i-write_xml-label-Parameters">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
776
+ <ul><li>
777
+ <p><code>xml</code> - Base Nokogiri::XML object used for building. If omitted,
778
+ a blank document will be generated.</p>
779
+ </li><li>
780
+ <p><code>node_name_override</code> - if present, is used instead of the
781
+ default element name for this object provided by
782
+ <code>define_element_name</code></p>
783
+ </li></ul>
784
+
785
+ <h4 id="method-i-write_xml-label-Examples">Examples<span><a href="#method-i-write_xml-label-Examples">&para;</a> <a href="#documentation">&uarr;</a></span></h4>
786
+
787
+ <pre>obj.write_xml</pre>
788
+
789
+ <p>Creates a new Nokogiti::XML and</p>
790
+
791
+
792
+
793
+
794
+ <div class="method-source-code" id="write_xml-source">
795
+ <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 142</span>
796
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">write_xml</span>(<span class="ruby-identifier">xml</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">node_name_override</span> = <span class="ruby-keyword">nil</span>)
797
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">then</span>
798
+ <span class="ruby-identifier">seed_xml</span> = <span class="ruby-constant">Nokogiri</span><span class="ruby-operator">::</span><span class="ruby-constant">XML</span>(<span class="ruby-string">'&lt;?xml version = &quot;1.0&quot; standalone =&quot;yes&quot;?&gt;'</span>)
799
+ <span class="ruby-identifier">seed_xml</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-string">'UTF-8'</span>
800
+ <span class="ruby-identifier">result</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">write_xml</span>(<span class="ruby-identifier">seed_xml</span>)
801
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">result</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">result</span> <span class="ruby-operator">==</span> <span class="ruby-string">''</span>
802
+ <span class="ruby-identifier">seed_xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">result</span>
803
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">seed_xml</span>.<span class="ruby-identifier">to_xml</span>({ <span class="ruby-value">:indent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-value">:save_with</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Nokogiri</span><span class="ruby-operator">::</span><span class="ruby-constant">XML</span><span class="ruby-operator">::</span><span class="ruby-constant">Node</span><span class="ruby-operator">::</span><span class="ruby-constant">SaveOptions</span><span class="ruby-operator">::</span><span class="ruby-constant">AS_XML</span> })
804
+ <span class="ruby-keyword">end</span>
805
+
806
+ <span class="ruby-keyword">return</span> <span class="ruby-string">''</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">before_write_xml</span>
807
+
808
+ <span class="ruby-identifier">attrs</span> = <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_namespaces</span>).<span class="ruby-identifier">dup</span>
809
+
810
+ <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_attributes</span>).<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
811
+ <span class="ruby-identifier">val</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>])
812
+
813
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">then</span>
814
+ <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">:optional</span>]
815
+ <span class="ruby-identifier">val</span> = <span class="ruby-identifier">v</span>[<span class="ruby-value">:default</span>]
816
+ <span class="ruby-keyword">end</span>
817
+
818
+ <span class="ruby-identifier">val</span> = <span class="ruby-identifier">val</span> <span class="ruby-operator">&amp;&amp;</span>
819
+ <span class="ruby-keyword">case</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">:attr_type</span>]
820
+ <span class="ruby-keyword">when</span> <span class="ruby-value">:bool</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">val</span> <span class="ruby-operator">?</span> <span class="ruby-string">'1'</span> <span class="ruby-operator">:</span> <span class="ruby-string">'0'</span>
821
+ <span class="ruby-keyword">when</span> <span class="ruby-value">:float</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\.0*$/</span>, <span class="ruby-string">''</span>) <span class="ruby-comment"># Trim trailing zeroes
822
+ <span class="ruby-keyword">else</span> <span class="ruby-identifier">val</span>
823
+ <span class="ruby-keyword">end</span>
824
+
825
+ <span class="ruby-identifier">attrs</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">val</span>
826
+ }
827
+
828
+ <span class="ruby-identifier">element_text</span> = <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">'_'</span>)
829
+ <span class="ruby-identifier">elem</span> = <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">create_element</span>(<span class="ruby-identifier">node_name_override</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_tag_name</span>), <span class="ruby-identifier">attrs</span>, <span class="ruby-identifier">element_text</span>)
830
+ <span class="ruby-identifier">child_nodes</span> = <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_child_nodes</span>)
831
+ <span class="ruby-identifier">child_nodes</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">child_node_name</span>, <span class="ruby-identifier">child_node_params</span><span class="ruby-operator">|</span>
832
+ <span class="ruby-identifier">obj</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">child_node_params</span>[<span class="ruby-value">:accessor</span>])
833
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">nil?</span>
834
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">child_node_params</span>[<span class="ruby-value">:is_array</span>] <span class="ruby-keyword">then</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span> <span class="ruby-identifier">elem</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">write_xml</span>(<span class="ruby-identifier">xml</span>, <span class="ruby-identifier">child_node_name</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">nil?</span> }
835
+ <span class="ruby-keyword">else</span> <span class="ruby-identifier">elem</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">write_xml</span>(<span class="ruby-identifier">xml</span>, <span class="ruby-identifier">child_node_name</span>)
836
+ <span class="ruby-keyword">end</span>
837
+ <span class="ruby-keyword">end</span>
838
+ }
839
+ <span class="ruby-identifier">elem</span>
840
+ <span class="ruby-keyword">end</span></pre>
841
+ </div>
842
+
843
+ </div>
844
+
845
+
846
+
847
+
848
+ </div>
849
+
850
+
851
+ </section>
852
+
853
+ </section>
854
+ </main>
855
+
856
+
857
+ <footer id="validator-badges" role="contentinfo">
858
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
859
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
860
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
861
+ </footer>
862
+