summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/num_data_source.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-10-14 11:34:51 +0900
committerRandy Morgan <[email protected]>2012-10-14 11:34:51 +0900
commita441bc1ff24c5b238203adb49b6e7ce208d5dabf (patch)
tree770da3a7384636a4cc0c35ff443d212a1ef47912 /lib/axlsx/drawing/num_data_source.rb
parente4d4538e1ea15b6aff9e4ef3fbc47c2e29ceb8be (diff)
downloadcaxlsx-a441bc1ff24c5b238203adb49b6e7ce208d5dabf.tar.gz
caxlsx-a441bc1ff24c5b238203adb49b6e7ce208d5dabf.zip
Refactored to use use options parser.
Diffstat (limited to 'lib/axlsx/drawing/num_data_source.rb')
-rw-r--r--lib/axlsx/drawing/num_data_source.rb33
1 files changed, 17 insertions, 16 deletions
diff --git a/lib/axlsx/drawing/num_data_source.rb b/lib/axlsx/drawing/num_data_source.rb
index 63f0d811..14d53301 100644
--- a/lib/axlsx/drawing/num_data_source.rb
+++ b/lib/axlsx/drawing/num_data_source.rb
@@ -3,18 +3,7 @@ module Axlsx
# A numeric data source for use by charts.
class NumDataSource
- # The tag name to use when serializing this data source.
- # Only items defined in allowed_tag_names are allowed
- # @return [Symbol]
- attr_reader :tag_name
-
- attr_reader :data
-
- # allowed element tag names
- # @return [Array]
- def self.allowed_tag_names
- [:yVal, :val]
- end
+ include Axlsx::OptionsParser
# creates a new NumDataSource object
# @option options [Array] data An array of Cells or Numeric objects
@@ -30,12 +19,24 @@ module Axlsx
if options[:data] && options[:data].first.is_a?(Cell)
@f = Axlsx::cell_range(options[:data])
end
- options.each do |o|
- self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
- end
+ parse_options options
+ end
+
+
+ # The tag name to use when serializing this data source.
+ # Only items defined in allowed_tag_names are allowed
+ # @return [Symbol]
+ attr_reader :tag_name
+
+ attr_reader :data
+
+ # allowed element tag names
+ # @return [Array]
+ def self.allowed_tag_names
+ [:yVal, :val]
end
- # sets the tag name for this data source
+ # sets the tag name for this data source
# @param [Symbol] v One of the allowed_tag_names
def tag_name=(v)
Axlsx::RestrictionValidator.validate "#{self.class.name}.tag_name", self.class.allowed_tag_names, v