Sha256: 45f295fb080819f2ac2fbbb05599143c6cb2cac094b49b56cad20b2c18029ebc
Contents?: true
Size: 1.45 KB
Versions: 17
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true module OoxmlParser # Class for parsing `w:shd` object class Shade < OOXMLDocumentObject # @return [Symbol] value of shade attr_accessor :value # @return [Symbol] color of shade attr_accessor :color # @return [Color] fill of shade attr_accessor :fill def initialize(value: nil, color: nil, fill: nil, parent: nil) @value = value @color = color @fill = fill super(parent: parent) end # @return [String] text representation def to_s "Value: `#{value}`, " \ "Color: `#{color}`, " \ "Fill: `#{fill}`" end # Parse Shade # @param [Nokogiri::XML:Node] node with Shade # @return [Shade] result of parsing 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 # Helper method to get background color # @return [OoxmlParser::Color] def to_background_color return nil unless fill background_color = fill background_color.set_style(value) if value background_color end extend Gem::Deprecate deprecate :to_background_color, 'use shade direct methods', 2077, 1 end end
Version data entries
17 entries across 17 versions & 1 rubygems