Class: OoxmlParser::Shade
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Shade
- Extended by:
- Gem::Deprecate
- Defined in:
- lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb
Overview
Class for parsing ‘w:shd` object
Instance Attribute Summary collapse
-
#color ⇒ Symbol
Color of shade.
-
#fill ⇒ Color
Fill of shade.
-
#value ⇒ Symbol
Value of shade.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(value: nil, color: nil, fill: nil, parent: nil) ⇒ Shade
constructor
A new instance of Shade.
-
#parse(node) ⇒ Shade
Parse Shade.
-
#to_background_color ⇒ OoxmlParser::Color
Helper method to get background color.
-
#to_s ⇒ String
Text representation.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(value: nil, color: nil, fill: nil, parent: nil) ⇒ Shade
Returns a new instance of Shade.
13 14 15 16 17 18 19 20 21 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 13 def initialize(value: nil, color: nil, fill: nil, parent: nil) @value = value @color = color @fill = fill super(parent: parent) end |
Instance Attribute Details
#color ⇒ Symbol
Returns color of shade.
9 10 11 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 9 def color @color end |
#fill ⇒ Color
Returns fill of shade.
11 12 13 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 11 def fill @fill end |
#value ⇒ Symbol
Returns value of shade.
7 8 9 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 7 def value @value end |
Instance Method Details
#parse(node) ⇒ Shade
Parse Shade
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 33 def parse(node) node.attributes.each do |key, value| case key when 'val' @value = value.value.to_sym when 'color' @color = value.value.to_sym when 'fill' @fill = Color.new(parent: self).parse_hex_string(value.value.to_s) end end self end |
#to_background_color ⇒ OoxmlParser::Color
Helper method to get background color
49 50 51 52 53 54 55 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 49 def to_background_color return nil unless fill background_color = fill background_color.set_style(value) if value background_color end |
#to_s ⇒ String
Returns text representation.
24 25 26 27 28 |
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 24 def to_s "Value: `#{value}`, " \ "Color: `#{color}`, " \ "Fill: `#{fill}`" end |