Sha256: 859c38d27d11f2f23c950beae19685c58d41cd71f29e38d48473a4b8a59735a2

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

module OoxmlParser
  # Class for parsing ThemeColor tags
  class ThemeColor < OOXMLDocumentObject
    attr_accessor :type, :value, :color

    def initialize(parent: nil)
      @type = ''
      @parent = parent
    end

    def ==(other)
      if other.is_a?(Color)
        @color == other
      else
        all_instance_variables = instance_variables
        all_instance_variables.each do |current_attributes|
          unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes)
            return false
          end
        end
        true
      end
    end

    # Parse ThemeColor
    # @param node [Nokogiri::XML::Element] node to parse
    # @return [ThemeColor] result of parsing
    def parse(color_node)
      color_node.xpath('*').each do |color_node_child|
        case color_node_child.name
        when 'sysClr'
          @type = :system
          @value = color_node_child.attribute('val').value
          @color = Color.new(parent: self).parse_hex_string(color_node_child.attribute('lastClr').value.to_s) unless color_node_child.attribute('lastClr').nil?
        when 'srgbClr'
          @type = :rgb
          @color = Color.new(parent: self).parse_hex_string(color_node_child.attribute('val').value.to_s)
        end
      end
      self
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ooxml_parser-0.2.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb