diff options
| author | Randy Morgan <[email protected]> | 2012-10-14 11:16:15 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-10-14 11:16:15 +0900 |
| commit | 93e8154b424a0effced6efe66d36156fe1d02acd (patch) | |
| tree | 08ccf3530140ec293f0d7613d2284190d392ae00 /lib/axlsx/stylesheet/gradient_fill.rb | |
| parent | a4e21e2e93ae227fb3e3bdf957c4e0b93fb0c90c (diff) | |
| download | caxlsx-93e8154b424a0effced6efe66d36156fe1d02acd.tar.gz caxlsx-93e8154b424a0effced6efe66d36156fe1d02acd.zip | |
extracted percentage validation for gradient fill left, right, top, bottom
Diffstat (limited to 'lib/axlsx/stylesheet/gradient_fill.rb')
| -rw-r--r-- | lib/axlsx/stylesheet/gradient_fill.rb | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/axlsx/stylesheet/gradient_fill.rb b/lib/axlsx/stylesheet/gradient_fill.rb index b4990a82..cfd51e64 100644 --- a/lib/axlsx/stylesheet/gradient_fill.rb +++ b/lib/axlsx/stylesheet/gradient_fill.rb @@ -54,18 +54,39 @@ module Axlsx # @return [SimpleTypedList] attr_reader :stop - # @see type + # @see type def type=(v) Axlsx::validate_gradient_type v; @type = v end + # @see degree 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) + validate_format_percentage "GradientFill.left", v + @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) + validate_format_percentage "GradientFill.right", v + @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) + validate_format_percentage "GradientFill.top", v + @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) + validate_format_percentage "GradientFill.bottom", v + @bottom = v + end + + def validate_format_percentage(name, value) + DataTypeValidator.validate name, Float, value, lambda { |arg| arg >= 0.0 && arg <= 1.0} + end # Serializes the object # @param [String] str |
