Class: Writexlsx::Worksheet::DataValidation
- Inherits:
-
Object
- Object
- Writexlsx::Worksheet::DataValidation
- Includes:
- Utility
- Defined in:
- lib/write_xlsx/worksheet/data_validation.rb
Overview
:nodoc:
Constant Summary
Constants included from Utility
Utility::COL_MAX, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX
Instance Attribute Summary collapse
-
#cells ⇒ Object
readonly
Returns the value of attribute cells.
-
#criteria ⇒ Object
readonly
Returns the value of attribute criteria.
-
#dropdown ⇒ Object
readonly
Returns the value of attribute dropdown.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#error_title ⇒ Object
readonly
Returns the value of attribute error_title.
-
#error_type ⇒ Object
readonly
Returns the value of attribute error_type.
-
#ignore_blank ⇒ Object
readonly
Returns the value of attribute ignore_blank.
-
#input_message ⇒ Object
readonly
Returns the value of attribute input_message.
-
#input_title ⇒ Object
readonly
Returns the value of attribute input_title.
-
#maximum ⇒ Object
readonly
Returns the value of attribute maximum.
-
#minimum ⇒ Object
readonly
Returns the value of attribute minimum.
-
#other_cells ⇒ Object
readonly
Returns the value of attribute other_cells.
-
#show_error ⇒ Object
readonly
Returns the value of attribute show_error.
-
#show_input ⇒ Object
readonly
Returns the value of attribute show_input.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#validate ⇒ Object
readonly
Returns the value of attribute validate.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(*args) ⇒ DataValidation
constructor
A new instance of DataValidation.
- #keys ⇒ Object
- #options_to_instance_variable(params) ⇒ Object
- #validate_none? ⇒ Boolean
-
#write_data_validation(writer) ⇒ Object
Write the <dataValidation> element.
Methods included from Utility
#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #convert_date_time, delete_files, #float_to_str, #pixels_to_points, #ptrue?, #put_deprecate_message, #row_col_notation, #shape_style_base, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #v_shape_attributes_base, #v_shape_style_base, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_div, #write_fill, #write_font, #write_stroke, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xml_str
Constructor Details
#initialize(*args) ⇒ DataValidation
Returns a new instance of DataValidation.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 13 def initialize(*args) # Check for a cell reference in A1 notation and substitute row and column. row1, col1, row2, col2, = row_col_notation(args) if row2.respond_to?(:keys) (row2.dup) row2, col2 = row1, col1 elsif .respond_to?(:keys) (.dup) else raise WriteXLSXInsufficientArgumentError end raise WriteXLSXInsufficientArgumentError if [row1, col1, row2, col2].include?(nil) check_for_valid_input_params check_dimensions(row1, col1) check_dimensions(row2, col2) @cells = [[row1, col1, row2, col2]] @value = @source if @source @value = @minimum if @minimum @validate = valid_validation_type[@validate.downcase] if @validate == 'none' @validate_none = true return end if ['list', 'custom'].include?(@validate) @criteria = 'between' @maximum = nil end check_criteria_required check_valid_citeria_types @criteria = valid_criteria_type[@criteria.downcase] check_maximum_value_when_criteria_is_between_or_notbetween @error_type = has_key?(:error_type) ? error_type_hash[@error_type.downcase] : 0 convert_date_time_value_if_required set_some_defaults # A (for now) undocumented parameter to pass additional cell ranges. @other_cells.each { |cells| @cells << cells } if has_key?(:other_cells) end |
Instance Attribute Details
#cells ⇒ Object (readonly)
Returns the value of attribute cells.
9 10 11 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 9 def cells @cells end |
#criteria ⇒ Object (readonly)
Returns the value of attribute criteria.
8 9 10 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 8 def criteria @criteria end |
#dropdown ⇒ Object (readonly)
Returns the value of attribute dropdown.
10 11 12 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 10 def dropdown @dropdown end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
11 12 13 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 11 def @error_message end |
#error_title ⇒ Object (readonly)
Returns the value of attribute error_title.
11 12 13 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 11 def error_title @error_title end |
#error_type ⇒ Object (readonly)
Returns the value of attribute error_type.
9 10 11 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 9 def error_type @error_type end |
#ignore_blank ⇒ Object (readonly)
Returns the value of attribute ignore_blank.
10 11 12 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 10 def ignore_blank @ignore_blank end |
#input_message ⇒ Object (readonly)
Returns the value of attribute input_message.
11 12 13 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 11 def @input_message end |
#input_title ⇒ Object (readonly)
Returns the value of attribute input_title.
11 12 13 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 11 def input_title @input_title end |
#maximum ⇒ Object (readonly)
Returns the value of attribute maximum.
8 9 10 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 8 def maximum @maximum end |
#minimum ⇒ Object (readonly)
Returns the value of attribute minimum.
8 9 10 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 8 def minimum @minimum end |
#other_cells ⇒ Object (readonly)
Returns the value of attribute other_cells.
9 10 11 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 9 def other_cells @other_cells end |
#show_error ⇒ Object (readonly)
Returns the value of attribute show_error.
10 11 12 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 10 def show_error @show_error end |
#show_input ⇒ Object (readonly)
Returns the value of attribute show_input.
10 11 12 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 10 def show_input @show_input end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 8 def source @source end |
#validate ⇒ Object (readonly)
Returns the value of attribute validate.
8 9 10 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 8 def validate @validate end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 8 def value @value end |
Instance Method Details
#keys ⇒ Object
64 65 66 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 64 def keys self.instance_variables.collect { |v| v.to_s.sub(/@/, '').to_sym } end |
#options_to_instance_variable(params) ⇒ Object
58 59 60 61 62 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 58 def (params) params.each do |k, v| instance_variable_set("@#{k}", v) end end |
#validate_none? ⇒ Boolean
68 69 70 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 68 def validate_none? @validate_none end |
#write_data_validation(writer) ⇒ Object
Write the <dataValidation> element.
75 76 77 78 79 80 81 82 83 |
# File 'lib/write_xlsx/worksheet/data_validation.rb', line 75 def write_data_validation(writer) #:nodoc: @writer = writer @writer.tag_elements('dataValidation', attributes) do # Write the formula1 element. write_formula_1(@value) # Write the formula2 element. write_formula_2(@maximum) if @maximum end end |