diff options
| author | Randy Morgan <[email protected]> | 2012-10-14 11:00:06 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-10-14 11:00:06 +0900 |
| commit | 393c2b8ac4b221d416581c02359ceb09f16ae8f3 (patch) | |
| tree | ac874331a58fddca1ff3e2ff3db232ea1b485233 /lib/axlsx/stylesheet/cell_style.rb | |
| parent | 553e7cf13358afe2a71c32082d5be6dbe939ad72 (diff) | |
| download | caxlsx-393c2b8ac4b221d416581c02359ceb09f16ae8f3.tar.gz caxlsx-393c2b8ac4b221d416581c02359ceb09f16ae8f3.zip | |
Refactored CellStyle to use options parser and serialized attributes
Diffstat (limited to 'lib/axlsx/stylesheet/cell_style.rb')
| -rw-r--r-- | lib/axlsx/stylesheet/cell_style.rb | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/lib/axlsx/stylesheet/cell_style.rb b/lib/axlsx/stylesheet/cell_style.rb index ed3aeda9..202c0cc2 100644 --- a/lib/axlsx/stylesheet/cell_style.rb +++ b/lib/axlsx/stylesheet/cell_style.rb @@ -4,6 +4,23 @@ module Axlsx # @note Using Styles#add_style is the recommended way to manage cell styling. # @see Styles#add_style class CellStyle + + include Axlsx::OptionsParser + include Axlsx::SerializedAttributes + + # Creats a new CellStyle object + # @option options [String] name + # @option options [Integer] xfId + # @option options [Integer] buildinId + # @option options [Integer] iLevel + # @option options [Boolean] hidden + # @option options [Boolean] customBuiltIn + def initialize(options={}) + parse_options options + end + + serializable_attributes :name, :xfId, :buildinId, :iLevel, :hidden, :customBuilin + # The name of this cell style # @return [String] attr_reader :name @@ -30,19 +47,7 @@ module Axlsx # @return [Boolean] attr_reader :customBuiltin - # Creats a new CellStyle object - # @option options [String] name - # @option options [Integer] xfId - # @option options [Integer] buildinId - # @option options [Integer] iLevel - # @option options [Boolean] hidden - # @option options [Boolean] customBuiltIn - def initialize(options={}) - options.each do |o| - self.send("#{o[0]}=", o[1]) if self.respond_to? o[0] - end - end - # @see name + # @see name def name=(v) Axlsx::validate_string v; @name = v end # @see xfId def xfId=(v) Axlsx::validate_unsigned_int v; @xfId = v end @@ -60,7 +65,7 @@ module Axlsx # @return [String] def to_xml_string(str = '') str << '<cellStyle ' - str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ') + serialized_attributes str str << '/>' end |
