Class: Axlsx::GradientFill
- Inherits:
-
Object
- Object
- Axlsx::GradientFill
- Includes:
- OptionsParser, SerializedAttributes
- Defined in:
- lib/axlsx/stylesheet/gradient_fill.rb
Overview
A GradientFill defines the color and positioning for gradient cell fill.
Instance Attribute Summary collapse
-
#bottom ⇒ Float
Percentage format bottom.
-
#degree ⇒ Float
Angle of the linear gradient.
-
#left ⇒ Float
Percentage format left.
-
#right ⇒ Float
Percentage format right.
-
#stop ⇒ SimpleTypedList
readonly
Collection of stop objects.
-
#top ⇒ Float
Percentage format top.
-
#type ⇒ Symbol
The type of gradient.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ GradientFill
constructor
Creates a new GradientFill object.
-
#to_xml_string(str = +'')) ⇒ String
Serializes the object.
-
#validate_format_percentage(name, value) ⇒ Object
validates that the value provided is between 0.0 and 1.0.
Methods included from SerializedAttributes
included, #serialized_attributes, #serialized_element_attributes, #serialized_tag
Methods included from OptionsParser
Constructor Details
#initialize(options = {}) ⇒ GradientFill
Creates a new GradientFill object
17 18 19 20 21 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 17 def initialize( = {}) [:type] ||= :linear @stop = SimpleTypedList.new GradientStop end |
Instance Attribute Details
#bottom ⇒ Float
Percentage format bottom
51 52 53 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 51 def bottom @bottom end |
#degree ⇒ Float
Angle of the linear gradient
35 36 37 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 35 def degree @degree end |
#left ⇒ Float
Percentage format left
39 40 41 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 39 def left @left end |
#right ⇒ Float
Percentage format right
43 44 45 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 43 def right @right end |
#stop ⇒ SimpleTypedList (readonly)
Collection of stop objects
55 56 57 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 55 def stop @stop end |
#top ⇒ Float
Percentage format top
47 48 49 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 47 def top @top end |
#type ⇒ Symbol
Note:
valid options are :linear :path
The type of gradient.
31 32 33 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 31 def type @type end |
Instance Method Details
#to_xml_string(str = +'')) ⇒ String
Serializes the object
101 102 103 104 105 106 107 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 101 def to_xml_string(str = +'') str << '<gradientFill ' serialized_attributes str str << '>' @stop.each { |s| s.to_xml_string(str) } str << '</gradientFill>' end |
#validate_format_percentage(name, value) ⇒ Object
validates that the value provided is between 0.0 and 1.0
94 95 96 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 94 def validate_format_percentage(name, value) DataTypeValidator.validate name, Float, value, ->(arg) { arg >= 0.0 && arg <= 1.0 } end |