summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/one_cell_anchor.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/one_cell_anchor.rb
parente4d4538e1ea15b6aff9e4ef3fbc47c2e29ceb8be (diff)
downloadcaxlsx-a441bc1ff24c5b238203adb49b6e7ce208d5dabf.tar.gz
caxlsx-a441bc1ff24c5b238203adb49b6e7ce208d5dabf.zip
Refactored to use use options parser.
Diffstat (limited to 'lib/axlsx/drawing/one_cell_anchor.rb')
-rw-r--r--lib/axlsx/drawing/one_cell_anchor.rb42
1 files changed, 20 insertions, 22 deletions
diff --git a/lib/axlsx/drawing/one_cell_anchor.rb b/lib/axlsx/drawing/one_cell_anchor.rb
index 9a202cc1..b16a939b 100644
--- a/lib/axlsx/drawing/one_cell_anchor.rb
+++ b/lib/axlsx/drawing/one_cell_anchor.rb
@@ -6,6 +6,26 @@ module Axlsx
# @see Worksheet#add_image
class OneCellAnchor
+ include Axlsx::OptionsParser
+
+ # Creates a new OneCellAnchor object and an Pic associated with it.
+ # @param [Drawing] drawing
+ # @option options [Array] start_at the col, row to start at
+ # @option options [Integer] width
+ # @option options [Integer] height
+ # @option options [String] image_src the file location of the image you will render
+ # @option options [String] name the name attribute for the rendered image
+ # @option options [String] descr the description of the image rendered
+ def initialize(drawing, options={})
+ @drawing = drawing
+ @width = 0
+ @height = 0
+ drawing.anchors << self
+ @from = Marker.new
+ parse_options options
+ @object = Pic.new(self, options)
+ end
+
# A marker that defines the from cell anchor. The default from column and row are 0 and 0 respectively
# @return [Marker]
attr_reader :from
@@ -28,27 +48,6 @@ module Axlsx
# @return [Integer]
attr_reader :height
-
- # Creates a new OneCellAnchor object and an Pic associated with it.
- # @param [Drawing] drawing
- # @option options [Array] start_at the col, row to start at
- # @option options [Integer] width
- # @option options [Integer] height
- # @option options [String] image_src the file location of the image you will render
- # @option options [String] name the name attribute for the rendered image
- # @option options [String] descr the description of the image rendered
- def initialize(drawing, options={})
- @drawing = drawing
- @width = 0
- @height = 0
- drawing.anchors << self
- @from = Marker.new
- options.each do |o|
- self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
- end
- @object = Pic.new(self, options)
- end
-
# @see height
def height=(v) Axlsx::validate_unsigned_int(v); @height = v; end
@@ -61,7 +60,6 @@ module Axlsx
@drawing.anchors.index(self)
end
-
# Serializes the object
# @param [String] str
# @return [String]