Sha256: ba0a5b20cc008abf2d81935f2115aa95036df1e6af14f12e07e99ea11957231a

Contents?: true

Size: 1.43 KB

Versions: 40

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

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

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

    # Compare ThemeColor with other object
    # @param other [Object] object to compare
    # @return [True, False] result of comparision
    def ==(other)
      if other.is_a?(Color)
        @color == other
      else
        all_instance_variables = instance_variables
        all_instance_variables.each do |current_attributes|
          return false unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes)
        end
        true
      end
    end

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

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ooxml_parser-0.21.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.20.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.19.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.18.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.18.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.17.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.16.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.15.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.14.2 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.14.1-mingw32 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.14.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.14.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.13.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.12.2 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.12.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.12.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.11.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.10.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.9.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb
ooxml_parser-0.9.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb