Class: Axlsx::GradientFill
- Inherits:
-
Object
- Object
- Axlsx::GradientFill
- Defined in:
- lib/axlsx/stylesheet/gradient_fill.rb
Overview
A GradientFill defines the color and positioning for gradiant 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.
Constructor Details
#initialize(options = {}) ⇒ GradientFill
Creates a new GradientFill object
46 47 48 49 50 51 52 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 46 def initialize(={}) [:type] ||= :linear .each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? o[0] end @stop = SimpleTypedList.new GradientStop end |
Instance Attribute Details
#bottom ⇒ Float
Percentage format bottom
33 34 35 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 33 def bottom @bottom end |
#degree ⇒ Float
Angle of the linear gradient
17 18 19 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 17 def degree @degree end |
#left ⇒ Float
Percentage format left
21 22 23 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 21 def left @left end |
#right ⇒ Float
Percentage format right
25 26 27 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 25 def right @right end |
#stop ⇒ SimpleTypedList (readonly)
Collection of stop objects
37 38 39 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 37 def stop @stop end |
#top ⇒ Float
Percentage format top
29 30 31 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 29 def top @top end |
#type ⇒ Symbol
Note:
valid options are
:linear
:path
The type of gradient.
13 14 15 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 13 def type @type end |
Instance Method Details
#to_xml_string(str = '') ⇒ String
Serializes the object
70 71 72 73 74 75 76 77 |
# File 'lib/axlsx/stylesheet/gradient_fill.rb', line 70 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 |