summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/workbook/worksheet/conditional_formatting.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-10-14 12:25:09 +0900
committerRandy Morgan <[email protected]>2012-10-14 12:25:09 +0900
commit93b70a39999ac4d06e43e495f3fd283e9630d9d2 (patch)
treebb2846edfc328ff9143c548c2a25eab23b8c9179 /lib/axlsx/workbook/worksheet/conditional_formatting.rb
parent5b5410845447772f4ba01b2ee5d03907f5897e7a (diff)
downloadcaxlsx-93b70a39999ac4d06e43e495f3fd283e9630d9d2.tar.gz
caxlsx-93b70a39999ac4d06e43e495f3fd283e9630d9d2.zip
Refactored to use options parser and serialized attributes.
Diffstat (limited to 'lib/axlsx/workbook/worksheet/conditional_formatting.rb')
-rw-r--r--lib/axlsx/workbook/worksheet/conditional_formatting.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/axlsx/workbook/worksheet/conditional_formatting.rb b/lib/axlsx/workbook/worksheet/conditional_formatting.rb
index 7ca07be6..eabf570e 100644
--- a/lib/axlsx/workbook/worksheet/conditional_formatting.rb
+++ b/lib/axlsx/workbook/worksheet/conditional_formatting.rb
@@ -6,6 +6,16 @@ module Axlsx
# @see ConditionalFormattingRule
class ConditionalFormatting
+ include Axlsx::OptionsParser
+
+ # Creates a new {ConditionalFormatting} object
+ # @option options [Array] rules The rules to apply
+ # @option options [String] sqref The range to apply the rules to
+ def initialize(options={})
+ @rules = []
+ parse_options options
+ end
+
# Range over which the formatting is applied, in "A1:B2" format
# @return [String]
attr_reader :sqref
@@ -18,17 +28,7 @@ module Axlsx
# @return [Array]
attr_reader :rules
- # Creates a new {ConditionalFormatting} object
- # @option options [Array] rules The rules to apply
- # @option options [String] sqref The range to apply the rules to
- def initialize(options={})
- @rules = []
- options.each do |o|
- self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
- end
- end
-
- # Add Conditional Formatting Rules to this object. Rules can either
+ # Add Conditional Formatting Rules to this object. Rules can either
# be already created {ConditionalFormattingRule} elements or
# hashes of options for automatic creation. If rules is a hash
# instead of an array, assume only one rule being added.