Class: ToSpreadsheet::Rule::DefaultValue
- Includes:
- TypeFromValue
- Defined in:
- lib/to_spreadsheet/rule/default_value.rb
Instance Attribute Summary
Attributes inherited from Base
#options, #selector_query, #selector_type
Instance Method Summary collapse
Methods included from TypeFromValue
Methods inherited from Base
#applies_to?, #initialize, #to_s, #type
Methods included from Selectors
#column_number_match?, #css_match, #css_match?, #each_cell, #query_match?, #range_contains?, #range_match, #row_number_match?
Constructor Details
This class inherits a constructor from ToSpreadsheet::Rule::Base
Instance Method Details
#apply(context, sheet) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/to_spreadsheet/rule/default_value.rb', line 7 def apply(context, sheet) default = each_cell context, sheet, selector_type, selector_query do |cell| unless cell.value.present? && !([:integer, :float].include?(cell.type) && cell.value.zero?) cell.type = cell_type_from_value(default) cell.value = default end end end |