Class: ToSpreadsheet::Rule::Container
- Defined in:
- lib/to_spreadsheet/rule/container.rb
Overview
Applies children rules to all the matching tables
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Attributes inherited from Base
#options, #selector_query, #selector_type
Instance Method Summary collapse
- #apply(context, package) ⇒ Object
-
#initialize(*args) ⇒ Container
constructor
A new instance of Container.
- #to_s ⇒ Object
Methods inherited from Base
Methods included from Selectors
#column_number_match?, #css_match, #css_match?, #each_cell, #query_match?, #range_contains?, #range_match, #row_number_match?
Constructor Details
#initialize(*args) ⇒ Container
Returns a new instance of Container.
6 7 8 9 |
# File 'lib/to_spreadsheet/rule/container.rb', line 6 def initialize(*args) super @children = [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
5 6 7 |
# File 'lib/to_spreadsheet/rule/container.rb', line 5 def children @children end |
Instance Method Details
#apply(context, package) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/to_spreadsheet/rule/container.rb', line 11 def apply(context, package) package.workbook.worksheets.each do |sheet| table = context.to_xml_node(sheet) if applies_to?(context, table) children.each { |c| c.apply(context, sheet) } end end end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/to_spreadsheet/rule/container.rb', line 20 def to_s "Rules(#{selector_type}, #{selector_query}) [#{children.map(&:to_s)}]" end |