lib/axlsx/stylesheet/cell_alignment.rb in axlsx-1.0.18 vs lib/axlsx/stylesheet/cell_alignment.rb in axlsx-1.1.0
- old
+ new
@@ -1,13 +1,13 @@
# encoding: UTF-8
module Axlsx
# CellAlignment stores information about the cell alignment of a style Xf Object.
- # @note Using Styles#add_style is the recommended way to manage cell alignment.
+ # @note Using Styles#add_style is the recommended way to manage cell alignment.
# @see Styles#add_style
class CellAlignment
# The horizontal alignment of the cell.
- # @note
+ # @note
# The horizontal cell alignement style must be one of
# :general
# :left
# :center
# :right
@@ -34,11 +34,11 @@
attr_reader :textRotation
# Indicate if the text of the cell should wrap
# @return [Boolean]
attr_reader :wrapText
-
+
# The amount of indent
# @return [Integer]
attr_reader :indent
# The amount of relativeIndent
@@ -52,16 +52,16 @@
# Indicate if the text should be shrunk to the fit in the cell.
# @return [Boolean]
attr_reader :shrinkToFit
# The reading order of the text
- # 0 Context Dependent
+ # 0 Context Dependent
# 1 Left-to-Right
# 2 Right-to-Left
# @return [Integer]
attr_reader :readingOrder
-
+
# Create a new cell_alignment object
# @option options [Symbol] horizontal
# @option options [Symbol] vertical
# @option options [Integer] textRotation
# @option options [Boolean] wrapText
@@ -72,35 +72,37 @@
# @option options [Integer] readingOrder
def initialize(options={})
options.each do |o|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
end
- end
-
+ end
+
# @see horizontal
- def horizontal=(v) Axlsx::validate_horizontal_alignment v; @horizontal = v end
+ def horizontal=(v) Axlsx::validate_horizontal_alignment v; @horizontal = v end
# @see vertical
- def vertical=(v) Axlsx::validate_vertical_alignment v; @vertical = v end
+ def vertical=(v) Axlsx::validate_vertical_alignment v; @vertical = v end
# @see textRotation
- def textRotation=(v) Axlsx::validate_unsigned_int v; @textRotation = v end
+ def textRotation=(v) Axlsx::validate_unsigned_int v; @textRotation = v end
# @see wrapText
- def wrapText=(v) Axlsx::validate_boolean v; @wrapText = v end
+ def wrapText=(v) Axlsx::validate_boolean v; @wrapText = v end
# @see indent
- def indent=(v) Axlsx::validate_unsigned_int v; @indent = v end
+ def indent=(v) Axlsx::validate_unsigned_int v; @indent = v end
# @see relativeIndent
- def relativeIndent=(v) Axlsx::validate_int v; @relativeIndent = v end
+ def relativeIndent=(v) Axlsx::validate_int v; @relativeIndent = v end
# @see justifyLastLine
- def justifyLastLine=(v) Axlsx::validate_boolean v; @justifyLastLine = v end
+ def justifyLastLine=(v) Axlsx::validate_boolean v; @justifyLastLine = v end
# @see shrinkToFit
- def shrinkToFit=(v) Axlsx::validate_boolean v; @shrinkToFit = v end
+ def shrinkToFit=(v) Axlsx::validate_boolean v; @shrinkToFit = v end
# @see readingOrder
- def readingOrder=(v) Axlsx::validate_unsigned_int v; @readingOrder = v end
+ def readingOrder=(v) Axlsx::validate_unsigned_int v; @readingOrder = v end
- # Serializes the cell alignment
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
+ # Serializes the object
+ # @param [String] str
# @return [String]
- def to_xml(xml)
- xml.alignment(self.instance_values)
+ def to_xml_string(str = '')
+ str << '<alignment '
+ str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
+ str << '/>'
end
-
+
end
end