summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/stylesheet/border.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-10-14 09:20:15 +0900
committerRandy Morgan <[email protected]>2012-10-14 09:20:15 +0900
commitfbd212ac7070627ec069f5e3a69d3e80475b6bf0 (patch)
tree2a7349125ea94c2642db92d77ef840077260c459 /lib/axlsx/stylesheet/border.rb
parentef1dee87627fbb2a7ef8d9f2da530d500311ddf7 (diff)
downloadcaxlsx-fbd212ac7070627ec069f5e3a69d3e80475b6bf0.tar.gz
caxlsx-fbd212ac7070627ec069f5e3a69d3e80475b6bf0.zip
refactored camelCase attributes to snake_case and implemented serializable attriubtes for Border
Aliases are provided for altered attriubte names
Diffstat (limited to 'lib/axlsx/stylesheet/border.rb')
-rw-r--r--lib/axlsx/stylesheet/border.rb26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/axlsx/stylesheet/border.rb b/lib/axlsx/stylesheet/border.rb
index d23e5476..6c104263 100644
--- a/lib/axlsx/stylesheet/border.rb
+++ b/lib/axlsx/stylesheet/border.rb
@@ -3,11 +3,17 @@ module Axlsx
# This class details a border used in Office Open XML spreadsheet styles.
class Border
+ include Axlsx::SerializedAttributes
+
+ serializable_attributes :diagonal_up, :diagonal_down, :outline
+
# @return [Boolean] The diagonal up property for the border that indicates if the border should include a diagonal line from the bottom left to the top right of the cell.
- attr_reader :diagonalUp
+ attr_reader :diagonal_up
+ alias :diagonalUp :diagonal_up
# @return [Boolean] The diagonal down property for the border that indicates if the border should include a diagonal line from the top left to the top right of the cell.
- attr_reader :diagonalDown
+ attr_reader :diagonal_down
+ alias :diagonalDown :diagonal_down
# @return [Boolean] The outline property for the border indicating that top, left, right and bottom borders should only be applied to the outside border of a range of cells.
attr_reader :outline
@@ -16,8 +22,8 @@ module Axlsx
attr_reader :prs
# Creates a new Border object
- # @option options [Boolean] diagonalUp
- # @option options [Boolean] diagonalDown
+ # @option options [Boolean] diagonal_up
+ # @option options [Boolean] diagonal_down
# @option options [Boolean] outline
# @example - Making a border
# p = Axlsx::Package.new
@@ -36,9 +42,13 @@ module Axlsx
end
# @see diagonalUp
- def diagonalUp=(v) Axlsx::validate_boolean v; @diagonalUp = v end
+ def diagonal_up=(v) Axlsx::validate_boolean v; @diagonal_up = v end
+ alias :diagonalUp= :diagonal_up=
+
# @see diagonalDown
- def diagonalDown=(v) Axlsx::validate_boolean v; @diagonalDown = v end
+ def diagonal_down=(v) Axlsx::validate_boolean v; @diagonal_down = v end
+ alias :diagonalDown= :diagonal_down=
+
# @see outline
def outline=(v) Axlsx::validate_boolean v; @outline = v end
@@ -47,9 +57,9 @@ module Axlsx
# @return [String]
def to_xml_string(str = '')
str << '<border '
- h = self.instance_values.select{ |k,v| [:diagonalUp, :diagonalDown, :outline].include? k }
- str << h.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
+ serialized_attributes str
str << '>'
+ # enforces order
[:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal].each do |k|
@prs.select { |pr| pr.name == k }.each do |part|
part.to_xml_string(str)