Sha256: 7f46ff4c91a31c52788e8b7921b377d176e2e960994e5eb25b5720b27279eafe

Contents?: true

Size: 904 Bytes

Versions: 6

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for color transformations
  class ColorProperties < OOXMLDocumentObject
    attr_accessor :alpha, :luminance_modulation, :luminance_offset
    attr_accessor :tint

    # Parse ColorProperties object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [ColorProperties] result of parsing
    def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'alpha'
          @alpha = (node_child.attribute('val').value.to_f / 1_000.0).round
        when 'lumMod'
          @luminance_modulation = node_child.attribute('val').value.to_f / 100_000.0
        when 'lumOff'
          @luminance_offset = node_child.attribute('val').value.to_f / 100_000.0
        when 'tint'
          @tint = node_child.attribute('val').value.to_f / 100_000.0
        end
      end
      self
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ooxml_parser-0.7.2 lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb
ooxml_parser-0.7.1 lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb
ooxml_parser-0.7.0 lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb
ooxml_parser-0.6.0 lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb
ooxml_parser-0.5.1 lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb
ooxml_parser-0.5.0 lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb