Sha256: c25fa0ab1a55c596b44fcbec066afce27da9366ab34b2658f7fce3dc2e4565aa

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Axlsx
  # CellProtection stores information about locking or hiding cells in spreadsheet.
  # @note Using Styles#add_style is the recommended way to manage cell protection.
  # @see Styles#add_style
  class CellProtection
    include Axlsx::OptionsParser
    include Axlsx::SerializedAttributes

    serializable_attributes :hidden, :locked

    # specifies locking for cells that have the style containing this protection
    # @return [Boolean]
    attr_reader :hidden

    # specifies if the cells that have the style containing this protection
    # @return [Boolean]
    attr_reader :locked

    # Creates a new CellProtection
    # @option options [Boolean] hidden value for hidden protection
    # @option options [Boolean] locked value for locked protection
    def initialize(options = {})
      parse_options options
    end

    # @see hidden
    def hidden=(v)
      Axlsx.validate_boolean v
      @hidden = v
    end

    # @see locked
    def locked=(v)
      Axlsx.validate_boolean v
      @locked = v
    end

    # Serializes the object
    # @param [String] str
    # @return [String]
    def to_xml_string(str = +'')
      serialized_tag('protection', str)
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
caxlsx-4.2.0 lib/axlsx/stylesheet/cell_protection.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/stylesheet/cell_protection.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/stylesheet/cell_protection.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/stylesheet/cell_protection.rb
caxlsx-4.1.0 lib/axlsx/stylesheet/cell_protection.rb