diff options
| author | Randy Morgan <[email protected]> | 2012-10-14 07:53:59 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-10-14 07:53:59 +0900 |
| commit | 88d8a35b400cd25b0e68edc13519dae5a9c4d4d6 (patch) | |
| tree | 83ce894c3be77b55174da9dc13478f5c7ecd05dc /lib | |
| parent | be95b7eaa72cd7007bc0fef22d0c3ea4fa3c3553 (diff) | |
| download | caxlsx-88d8a35b400cd25b0e68edc13519dae5a9c4d4d6.tar.gz caxlsx-88d8a35b400cd25b0e68edc13519dae5a9c4d4d6.zip | |
Extracted attriubte serialization
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx.rb | 1 | ||||
| -rw-r--r-- | lib/axlsx/util/serialized_attributes.rb | 24 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/sheet_pr.rb | 27 |
3 files changed, 44 insertions, 8 deletions
diff --git a/lib/axlsx.rb b/lib/axlsx.rb index 394a0806..00438425 100644 --- a/lib/axlsx.rb +++ b/lib/axlsx.rb @@ -6,6 +6,7 @@ require 'axlsx/util/simple_typed_list.rb' require 'axlsx/util/constants.rb' require 'axlsx/util/validators.rb' require 'axlsx/util/accessors.rb' +require 'axlsx/util/serialized_attributes' # to be included with parsable intitites. #require 'axlsx/util/parser.rb' diff --git a/lib/axlsx/util/serialized_attributes.rb b/lib/axlsx/util/serialized_attributes.rb new file mode 100644 index 00000000..84a7733e --- /dev/null +++ b/lib/axlsx/util/serialized_attributes.rb @@ -0,0 +1,24 @@ +module Axlsx + module SerializedAttributes + + def self.included(base) + base.send :extend, ClassMethods + end + + module ClassMethods + def serializable_attributes(*symbols) + @@serializable_attributes = symbols + end + end + + def serialized_attributes(str = '') + serializable_values = instance_values.select do |key, value| + self.class.serializable_attributes.include?(key.to_sym) + end + serializable_values.each do |key, value| + str << "#{Axlsx.camel(key, false)}='#{value}' " + end + str + end + end +end diff --git a/lib/axlsx/workbook/worksheet/sheet_pr.rb b/lib/axlsx/workbook/worksheet/sheet_pr.rb index 79e10ca0..aa737707 100644 --- a/lib/axlsx/workbook/worksheet/sheet_pr.rb +++ b/lib/axlsx/workbook/worksheet/sheet_pr.rb @@ -4,6 +4,17 @@ module Axlsx class SheetPr include Axlsx::Accessors + include Axlsx::SerializedAttributes + + serializable_attributes :sync_horizontal, + :sync_vertical, + :transtion_evaluation, + :transition_entry, + :published, + :filter_mode, + :enable_format_conditions_calculation, + :code_name, + :sync_ref # These attributes are all boolean so I'm doing a bit of a hand # waving magic show to set up the attriubte accessors @@ -50,14 +61,14 @@ module Axlsx private - def serialized_attributes(str = '') - instance_values.each do |key, value| - unless %(worksheet page_setup_pr).include? key - str << "#{Axlsx.camel(key, false)}='#{value}' " - end - end - str - end + # def serialized_attributes(str = '') + #instance_values.each do |key, value| + #unless %(worksheet page_setup_pr).include? key + #str << "#{Axlsx.camel(key, false)}='#{value}' " + #end + #end + #str + #end def update_properties page_setup_pr.fit_to_page = worksheet.fit_to_page? |
