diff options
| author | Randy Morgan <[email protected]> | 2011-11-26 13:20:57 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2011-11-26 13:20:57 +0900 |
| commit | 11303a4d6664d9a7ff7bc408035d2ab70378a375 (patch) | |
| tree | 51c675ae3ab8cd6c1afd7087145261b1eb2ec54c /lib/axlsx/drawing/pic.rb | |
| parent | 044afe5a35db42cefce4f18a0fecc3da90cab1b5 (diff) | |
| download | caxlsx-11303a4d6664d9a7ff7bc408035d2ab70378a375.tar.gz caxlsx-11303a4d6664d9a7ff7bc408035d2ab70378a375.zip | |
adding in support for ruby 1.9.3
release version 1.0.9
Diffstat (limited to 'lib/axlsx/drawing/pic.rb')
| -rw-r--r-- | lib/axlsx/drawing/pic.rb | 66 |
1 files changed, 29 insertions, 37 deletions
diff --git a/lib/axlsx/drawing/pic.rb b/lib/axlsx/drawing/pic.rb index 7043df35..84e750ce 100644 --- a/lib/axlsx/drawing/pic.rb +++ b/lib/axlsx/drawing/pic.rb @@ -10,50 +10,22 @@ module Axlsx # The name to use for this picture # @return [String] - attr_accessor :name + attr_reader :name - # providing access to the anchor's width attribute - # @param [Integer] v - # @see OneCellAnchor.width - attr_accessor :width - - # providing access to update the anchor's height attribute - # @param [Integer] v - # @see OneCellAnchor.width - attr_accessor :height # A description of the picture # @return [String] - attr_accessor :descr + attr_reader :descr # The path to the image you want to include # Only local images are supported at this time and only jpg support # @return [String] - attr_accessor :image_src + attr_reader :image_src # The anchor for this image # @return [OneCellAnchor] attr_reader :anchor - # returns the extension of image_src without the preceeding '.' - # @return [String] - attr_reader :extname - - # The file name of image_src without any path information - # @return [String] - attr_reader :file_name - - # The part name for this image used in serialization and relationship building - # @return [String] - attr_reader :pn - - # The index of this image in the workbooks images collections - # @return [Index] - attr_reader :index - - # The name of the image file, sans directory info - # @return [String] - attr_reader :file_name # Creates a new Pic(ture) object # @param [Anchor] anchor the anchor that holds this image @@ -69,7 +41,7 @@ module Axlsx options.each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end - start_at *options[:start_at] if options[:start_at] + start_at(*options[:start_at]) if options[:start_at] yield self if block_given? end @@ -80,41 +52,61 @@ module Axlsx @image_src = v end + # @see name def name=(v) Axlsx::validate_string(v); @name = v; end + + # @see descr def descr=(v) Axlsx::validate_string(v); @descr = v; end + + # The file name of image_src without any path information + # @return [String] def file_name File.basename(image_src) unless image_src.nil? end + # returns the extension of image_src without the preceeding '.' + # @return [String] def extname File.extname(image_src).delete('.') unless image_src.nil? end + # The index of this image in the workbooks images collections + # @return [Index] def index @anchor.drawing.worksheet.workbook.images.index(self) end - + + # The part name for this image used in serialization and relationship building + # @return [String] def pn "#{IMAGE_PN % [(index+1), extname]}" end + # providing access to the anchor's width attribute + # @param [Integer] v + # @see OneCellAnchor.width def width @anchor.width end + # @see width def width=(v) @anchor.width = v end - def height=(v) - @anchor.height = v - end - + # providing access to update the anchor's height attribute + # @param [Integer] v + # @see OneCellAnchor.width def height @anchor.height end + # @see height + def height=(v) + @anchor.height = v + end + # This is a short cut method to set the start anchor position # If you need finer granularity in positioning use # graphic_frame.anchor.from.colOff / rowOff |
