From eb24621d853b42cb2d540955c08cb232dfa3dd71 Mon Sep 17 00:00:00 2001 From: Jonathan Tron Date: Sat, 4 Jul 2015 12:19:37 +0200 Subject: Add a little bit of doc, remove warning by using attr_reader --- lib/axlsx/drawing/pic.rb | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/axlsx/drawing/pic.rb b/lib/axlsx/drawing/pic.rb index d38d2b6d..275a6d06 100644 --- a/lib/axlsx/drawing/pic.rb +++ b/lib/axlsx/drawing/pic.rb @@ -9,12 +9,13 @@ module Axlsx # Creates a new Pic(ture) object # @param [Anchor] anchor the anchor that holds this image - # @option options [String] name - # @option options [String] descr - # @option options [String] image_src - # @option options [Array] start_at - # @option options [Intger] width - # @option options [Intger] height + # @option options [String] :name + # @option options [String] :descr + # @option options [String] :image_src + # @option options [Array] :start_at + # @option options [Integer] :width + # @option options [Integer] :height + # @option options [Float] :opacity - set the picture opacity, accepts a value between 0.0 and 1.0 def initialize(anchor, options={}) @anchor = anchor @hyperlink = nil @@ -23,7 +24,7 @@ module Axlsx start_at(*options[:start_at]) if options[:start_at] yield self if block_given? @picture_locking = PictureLocking.new(options) - @opacity = (options[:opacity] * 100000).round if options[:opacity] #accepts value beween 0..1 + @opacity = (options[:opacity] * 100000).round if options[:opacity] end # allowed mime types @@ -51,19 +52,23 @@ module Axlsx attr_reader :hyperlink + # Picture opacity + # @return [Fixnum] + attr_reader :opacity + # sets or updates a hyperlink for this image. # @param [String] v The href value for the hyper link # @option options @see Hyperlink#initialize All options available to the Hyperlink class apply - however href will be overridden with the v parameter value. def hyperlink=(v, options={}) options[:href] = v - if @hyperlink.is_a?(Hyperlink) + if hyperlink.is_a?(Hyperlink) options.each do |o| - @hyperlink.send("#{o[0]}=", o[1]) if @hyperlink.respond_to? "#{o[0]}=" + hyperlink.send("#{o[0]}=", o[1]) if hyperlink.respond_to? "#{o[0]}=" end else @hyperlink = Hyperlink.new(self, options) end - @hyperlink + hyperlink end def image_src=(v) @@ -79,7 +84,6 @@ module Axlsx # @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 @@ -167,14 +171,14 @@ module Axlsx str << '' str << '' str << ('') - @hyperlink.to_xml_string(str) if @hyperlink.is_a?(Hyperlink) + hyperlink.to_xml_string(str) if hyperlink.is_a?(Hyperlink) str << '' picture_locking.to_xml_string(str) str << '' str << '' str << ('') - if @opacity - str << "" + if opacity + str << "" end str << '' str << '' -- cgit v1.2.3