From a09f09952359dbadacb9f649d89fa7111af23bee Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Wed, 18 Jul 2012 17:25:55 +0900 Subject: dynamic docs… hmmm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/axlsx/drawing/d_lbls.rb | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/axlsx/drawing/d_lbls.rb b/lib/axlsx/drawing/d_lbls.rb index b1c010f1..6682bd07 100644 --- a/lib/axlsx/drawing/d_lbls.rb +++ b/lib/axlsx/drawing/d_lbls.rb @@ -1,5 +1,9 @@ module Axlsx - # + # There are more elements in the dLbls spec that allow for + # customizations and formatting. For now, I am just implementing the + # basics. + # + # # # # @@ -12,6 +16,9 @@ module Axlsx #The DLbls class manages serialization of data labels class DLbls + + # These attributes are all boolean so I'm doing a bit of a hand + # waving magic show to set up the attriubte accessors BOOLEAN_ATTRIBUTES = [:show_legend_key, :show_val, :show_cat_name, :show_ser_name, :show_percent, :show_bubble_size, :show_leader_lines] # creates a new DLbls object @@ -24,12 +31,17 @@ module Axlsx end + # Initialize all the values to false as Excel requires them to + # explicitly be disabled or all will show. def initialize_defaults BOOLEAN_ATTRIBUTES.each do |attr| self.send("#{attr}=", false) end end + # The position of the data labels in the chart + # @see d_lbl_pos= for a list of allowed values + # @return [Symbol] attr_reader :d_lbl_pos # @see DLbls#d_lbl_pos @@ -43,13 +55,19 @@ module Axlsx @d_lbl_pos = label_position end + # Dynamically create accessors for boolean attriubtes BOOLEAN_ATTRIBUTES.each do |attr| class_eval %{ + # The #{attr} attribute reader + # @return [Boolean] attr_reader :#{attr} - def #{attr}=(v) - Axlsx::validate_boolean(v) - @#{attr} = v + # The #{attr} writer + # @param [Boolean] value The value to assign to #{attr} + # @return [Boolean] + def #{attr}=(value) + Axlsx::validate_boolean(value) + @#{attr} = value end } end -- cgit v1.2.3