From fbd212ac7070627ec069f5e3a69d3e80475b6bf0 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sun, 14 Oct 2012 09:20:15 +0900 Subject: refactored camelCase attributes to snake_case and implemented serializable attriubtes for Border Aliases are provided for altered attriubte names --- lib/axlsx/stylesheet/border.rb | 26 ++++++++++++++++++-------- 1 file 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 << '' + # 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) -- cgit v1.2.3