summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/d_lbls.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-07-18 17:25:55 +0900
committerRandy Morgan <[email protected]>2012-07-18 17:25:55 +0900
commita09f09952359dbadacb9f649d89fa7111af23bee (patch)
tree2643288f04aa16d0f2b6d2ce6f225db236d2b5c3 /lib/axlsx/drawing/d_lbls.rb
parent51ec0287e61e4c65e6312d041869ccd9a9538c84 (diff)
downloadcaxlsx-a09f09952359dbadacb9f649d89fa7111af23bee.tar.gz
caxlsx-a09f09952359dbadacb9f649d89fa7111af23bee.zip
dynamic docs… hmmm
Diffstat (limited to 'lib/axlsx/drawing/d_lbls.rb')
-rw-r--r--lib/axlsx/drawing/d_lbls.rb26
1 files changed, 22 insertions, 4 deletions
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
- # <c:dLbls>
+ # There are more elements in the dLbls spec that allow for
+ # customizations and formatting. For now, I am just implementing the
+ # basics.
+ #
+ #<c:dLbls>
#<c:dLblPos val="outEnd"/>
#<c:showLegendKey val="0"/>
#<c:showVal val="0"/>
@@ -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