diff options
| author | Randy Morgan <[email protected]> | 2012-10-14 12:02:40 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-10-14 12:02:40 +0900 |
| commit | 5b5410845447772f4ba01b2ee5d03907f5897e7a (patch) | |
| tree | ce66d2add8423cf23b1c1a0bc35162c7447075ee /lib/axlsx/stylesheet/table_styles.rb | |
| parent | a441bc1ff24c5b238203adb49b6e7ce208d5dabf (diff) | |
| download | caxlsx-5b5410845447772f4ba01b2ee5d03907f5897e7a.tar.gz caxlsx-5b5410845447772f4ba01b2ee5d03907f5897e7a.zip | |
Refactored to use options parser and serialized attributes
Diffstat (limited to 'lib/axlsx/stylesheet/table_styles.rb')
| -rw-r--r-- | lib/axlsx/stylesheet/table_styles.rb | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/axlsx/stylesheet/table_styles.rb b/lib/axlsx/stylesheet/table_styles.rb index a43e7ce5..6ef07c51 100644 --- a/lib/axlsx/stylesheet/table_styles.rb +++ b/lib/axlsx/stylesheet/table_styles.rb @@ -4,13 +4,7 @@ module Axlsx # @note Support for custom table styles does not exist in this version. Many of the classes required are defined in preparation for future release. Please do not attempt to add custom table styles. class TableStyles < SimpleTypedList - # The default table style. The default value is 'TableStyleMedium9' - # @return [String] - attr_reader :defaultTableStyle - - # The default pivot table style. The default value is 'PivotStyleLight6' - # @return [String] - attr_reader :defaultPivotStyle + include Axlsx::SerializedAttributes # Creates a new TableStyles object that is a container for TableStyle objects # @option options [String] defaultTableStyle @@ -20,7 +14,18 @@ module Axlsx @defaultPivotStyle = options[:defaultPivotStyle] || "PivotStyleLight16" super TableStyle end - # @see defaultTableStyle + + serializable_attributes :defaultTableStyle, :defaultPivotStyle + + # The default table style. The default value is 'TableStyleMedium9' + # @return [String] + attr_reader :defaultTableStyle + + # The default pivot table style. The default value is 'PivotStyleLight6' + # @return [String] + attr_reader :defaultPivotStyle + + # @see defaultTableStyle def defaultTableStyle=(v) Axlsx::validate_string(v); @defaultTableStyle = v; end # @see defaultPivotStyle def defaultPivotStyle=(v) Axlsx::validate_string(v); @defaultPivotStyle = v; end @@ -29,10 +34,8 @@ module Axlsx # @param [String] str # @return [String] def to_xml_string(str = '') - attr = self.instance_values.reject {|k, v| ![:defaultTableStyle, :defaultPivotStyle].include?(k.to_sym) } - attr[:count] = self.size str << '<tableStyles ' - str << attr.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ') + serialized_attributes str, {:count => self.size } str << '>' each { |table_style| table_style.to_xml_string(str) } str << '</tableStyles>' |
