diff options
| author | Randy Morgan <[email protected]> | 2012-04-01 11:58:09 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-04-01 11:58:09 +0900 |
| commit | 1529fce32449a8454208fded20d83c9ceca810e0 (patch) | |
| tree | 02f722182fea58a51b8c0a5433221b3a677e80e4 /lib/axlsx/stylesheet/gradient_fill.rb | |
| parent | 22a341841f191a5aa00e87b1f166b4f25cc67f0a (diff) | |
| download | caxlsx-1529fce32449a8454208fded20d83c9ceca810e0.tar.gz caxlsx-1529fce32449a8454208fded20d83c9ceca810e0.zip | |
rebuild all serialization to use string concatenation instead of nokogiri.
Diffstat (limited to 'lib/axlsx/stylesheet/gradient_fill.rb')
| -rw-r--r-- | lib/axlsx/stylesheet/gradient_fill.rb | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/axlsx/stylesheet/gradient_fill.rb b/lib/axlsx/stylesheet/gradient_fill.rb index 6090b570..2a789c6f 100644 --- a/lib/axlsx/stylesheet/gradient_fill.rb +++ b/lib/axlsx/stylesheet/gradient_fill.rb @@ -1,11 +1,11 @@ # encoding: UTF-8 module Axlsx # A GradientFill defines the color and positioning for gradiant cell fill. - # @see Open Office XML Part 1 §18.8.24 + # @see Open Office XML Part 1 §18.8.24 class GradientFill # The type of gradient. - # @note + # @note # valid options are # :linear # :path @@ -26,7 +26,7 @@ module Axlsx # Percentage format top # @return [Float] - attr_reader :top + attr_reader :top # Percentage format bottom # @return [Float] @@ -35,7 +35,7 @@ module Axlsx # Collection of stop objects # @return [SimpleTypedList] attr_reader :stop - + # Creates a new GradientFill object # @option options [Symbol] type # @option options [Float] degree @@ -52,18 +52,27 @@ module Axlsx end # @see type - def type=(v) Axlsx::validate_gradient_type v; @type = v end + def type=(v) Axlsx::validate_gradient_type v; @type = v end # @see degree - def degree=(v) Axlsx::validate_float v; @degree = v end + def degree=(v) Axlsx::validate_float v; @degree = v end # @see left - def left=(v) DataTypeValidator.validate "GradientFill.left", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @left = v end + def left=(v) DataTypeValidator.validate "GradientFill.left", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @left = v end # @see right - def right=(v) DataTypeValidator.validate "GradientFill.right", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @right = v end + def right=(v) DataTypeValidator.validate "GradientFill.right", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @right = v end # @see top - def top=(v) DataTypeValidator.validate "GradientFill.top", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @top = v end + def top=(v) DataTypeValidator.validate "GradientFill.top", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @top = v end # @see bottom - def bottom=(v) DataTypeValidator.validate "GradientFill.bottom", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @bottom= v end + def bottom=(v) DataTypeValidator.validate "GradientFill.bottom", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @bottom= v end + + def to_xml_string(str = '') + str << '<gradientFill' + h = self.instance_values.reject { |k,v| k.to_sym == :stop } + str << h.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ') + str << '>' + @stop.each { |s| s.to_xml_string(str) } + str << '</gradientFill>' + end # Serializes the gradientFill # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. # @return [String] |
