From 393c2b8ac4b221d416581c02359ceb09f16ae8f3 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sun, 14 Oct 2012 11:00:06 +0900 Subject: Refactored CellStyle to use options parser and serialized attributes --- lib/axlsx/stylesheet/cell_style.rb | 33 +++++++++++++++++++-------------- 1 file 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 << '' end -- cgit v1.2.3