Class: Xlsxrb::Elements::Column
- Inherits:
-
Data
- Object
- Data
- Xlsxrb::Elements::Column
- Defined in:
- lib/xlsxrb/elements/column.rb
Overview
Represents column formatting in a worksheet. index is 0-based.
Instance Attribute Summary collapse
-
#custom_width ⇒ Object
readonly
Returns the value of attribute custom_width.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#hidden ⇒ Object
readonly
Returns the value of attribute hidden.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#outline_level ⇒ Object
readonly
Returns the value of attribute outline_level.
-
#unmapped_data ⇒ Object
readonly
Returns the value of attribute unmapped_data.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(index:, width: nil, hidden: false, custom_width: false, outline_level: nil, unmapped_data: {}, errors: nil) ⇒ Column
constructor
A new instance of Column.
- #valid? ⇒ Boolean
Constructor Details
#initialize(index:, width: nil, hidden: false, custom_width: false, outline_level: nil, unmapped_data: {}, errors: nil) ⇒ Column
Returns a new instance of Column.
8 9 10 11 12 13 14 |
# File 'lib/xlsxrb/elements/column.rb', line 8 def initialize(index:, width: nil, hidden: false, custom_width: false, outline_level: nil, unmapped_data: {}, errors: nil) computed_errors = errors || self.class.validate(index) super(index: index, width: width, hidden: hidden, custom_width: custom_width, outline_level: outline_level, unmapped_data: unmapped_data, errors: computed_errors.freeze) end |
Instance Attribute Details
#custom_width ⇒ Object (readonly)
Returns the value of attribute custom_width
7 8 9 |
# File 'lib/xlsxrb/elements/column.rb', line 7 def custom_width @custom_width end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors
7 8 9 |
# File 'lib/xlsxrb/elements/column.rb', line 7 def errors @errors end |
#hidden ⇒ Object (readonly)
Returns the value of attribute hidden
7 8 9 |
# File 'lib/xlsxrb/elements/column.rb', line 7 def hidden @hidden end |
#index ⇒ Object (readonly)
Returns the value of attribute index
7 8 9 |
# File 'lib/xlsxrb/elements/column.rb', line 7 def index @index end |
#outline_level ⇒ Object (readonly)
Returns the value of attribute outline_level
7 8 9 |
# File 'lib/xlsxrb/elements/column.rb', line 7 def outline_level @outline_level end |
#unmapped_data ⇒ Object (readonly)
Returns the value of attribute unmapped_data
7 8 9 |
# File 'lib/xlsxrb/elements/column.rb', line 7 def unmapped_data @unmapped_data end |
#width ⇒ Object (readonly)
Returns the value of attribute width
7 8 9 |
# File 'lib/xlsxrb/elements/column.rb', line 7 def width @width end |
Class Method Details
.validate(index) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/xlsxrb/elements/column.rb', line 20 def self.validate(index) errs = [] errs << "index must be a non-negative Integer (got #{index.inspect})" if !index.is_a?(Integer) || index.negative? errs << "index must be < 16384 (got #{index}, max column is XFD=16383)" if index.is_a?(Integer) && index >= 16_384 errs end |
Instance Method Details
#valid? ⇒ Boolean
16 17 18 |
# File 'lib/xlsxrb/elements/column.rb', line 16 def valid? errors.empty? end |