Class: OoxmlParser::ColorProperties

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb

Overview

Class for color transformations

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#alpha_objectValuedChild (readonly)

Returns alpha value of color object.

Returns:



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb', line 7

def alpha_object
  @alpha_object
end

#luminance_modulation_objectValuedChild (readonly)

Returns luminance modulation value object.

Returns:



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb', line 9

def luminance_modulation_object
  @luminance_modulation_object
end

#luminance_offset_objectValuedChild (readonly)

Returns luminance offset value object.

Returns:



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb', line 11

def luminance_offset_object
  @luminance_offset_object
end

#tint_objectValuedChild (readonly)

Returns tint value object.

Returns:



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb', line 13

def tint_object
  @tint_object
end

Instance Method Details

#alphaInteger

Returns alpha value.

Returns:

  • (Integer)

    alpha value



35
36
37
# File 'lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb', line 35

def alpha
  (@alpha_object.value / 1_000.0).round
end

#luminance_modulationFloat

Returns luminance modulation value.

Returns:

  • (Float)

    luminance modulation value



40
41
42
# File 'lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb', line 40

def luminance_modulation
  @luminance_modulation_object.value / 100_000.0
end

#luminance_offsetFloat

Returns luminance offset value.

Returns:

  • (Float)

    luminance offset value



45
46
47
# File 'lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb', line 45

def luminance_offset
  @luminance_offset_object.value / 100_000.0
end

#parse(node) ⇒ ColorProperties

Parse ColorProperties object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb', line 18

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'alpha'
      @alpha_object = ValuedChild.new(:float, parent: self).parse(node_child)
    when 'lumMod'
      @luminance_modulation_object = ValuedChild.new(:float, parent: self).parse(node_child)
    when 'lumOff'
      @luminance_offset_object = ValuedChild.new(:float, parent: self).parse(node_child)
    when 'tint'
      @tint_object = ValuedChild.new(:float, parent: self).parse(node_child)
    end
  end
  self
end

#tintnil, Float

Returns tint value.

Returns:

  • (nil, Float)

    tint value



50
51
52
53
54
# File 'lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb', line 50

def tint
  return nil unless @tint_object

  @tint_object.value / 100_000.0
end