Class: Axlsx::ProtectedRanges
- Inherits:
-
SimpleTypedList
- Object
- SimpleTypedList
- Axlsx::ProtectedRanges
- Defined in:
- lib/axlsx/workbook/worksheet/protected_ranges.rb
Overview
A self serializing collection of ranges that should be protected in the worksheet
Instance Attribute Summary collapse
-
#worksheet ⇒ Object
readonly
Returns the value of attribute worksheet.
Instance Method Summary collapse
-
#add_range(cells) ⇒ Object
Adds a protected range.
-
#initialize(worksheet) ⇒ ProtectedRanges
constructor
A new instance of ProtectedRanges.
- #to_xml_string(str = '') ⇒ Object
Constructor Details
#initialize(worksheet) ⇒ ProtectedRanges
Returns a new instance of ProtectedRanges.
9 10 11 12 13 |
# File 'lib/axlsx/workbook/worksheet/protected_ranges.rb', line 9 def initialize(worksheet) raise ArgumentError, 'You must provide a worksheet' unless worksheet.is_a?(Worksheet) super ProtectedRange @worksheet = worksheet end |
Instance Attribute Details
#worksheet ⇒ Object (readonly)
Returns the value of attribute worksheet.
7 8 9 |
# File 'lib/axlsx/workbook/worksheet/protected_ranges.rb', line 7 def worksheet @worksheet end |
Instance Method Details
#add_range(cells) ⇒ Object
Adds a protected range
17 18 19 20 21 22 23 24 25 |
# File 'lib/axlsx/workbook/worksheet/protected_ranges.rb', line 17 def add_range(cells) sqref = if cells.is_a?(String) cells elsif cells.is_a?(SimpleTypedList) || cells.is_a?(Array) Axlsx::cell_range(cells, false) end @list << ProtectedRange.new(:sqref => sqref, :name => "Range#{size}") last end |
#to_xml_string(str = '') ⇒ Object
27 28 29 30 31 32 |
# File 'lib/axlsx/workbook/worksheet/protected_ranges.rb', line 27 def to_xml_string(str = '') return if empty? str << '<protectedRanges>' each { |range| range.to_xml_string(str) } str << '</protectedRanges>' end |