Class: OoxmlParser::ColorProperties
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::ColorProperties
- Defined in:
- lib/ooxml_parser/common_parser/common_data/colors/color_properties.rb
Overview
Class for color transformations
Instance Attribute Summary collapse
-
#alpha_object ⇒ ValuedChild
readonly
Alpha value of color object.
-
#luminance_modulation_object ⇒ ValuedChild
readonly
Luminance modulation value object.
-
#luminance_offset_object ⇒ ValuedChild
readonly
Luminance offset value object.
-
#tint_object ⇒ ValuedChild
readonly
Tint value object.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#alpha ⇒ Integer
Alpha value.
-
#luminance_modulation ⇒ Float
Luminance modulation value.
-
#luminance_offset ⇒ Float
Luminance offset value.
-
#parse(node) ⇒ ColorProperties
Parse ColorProperties object.
-
#tint ⇒ nil, Float
Tint value.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
This class inherits a constructor from OoxmlParser::OOXMLDocumentObject
Instance Attribute Details
#alpha_object ⇒ ValuedChild (readonly)
Returns alpha value of color object.
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_object ⇒ ValuedChild (readonly)
Returns luminance modulation value object.
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_object ⇒ ValuedChild (readonly)
Returns luminance offset value object.
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_object ⇒ ValuedChild (readonly)
Returns tint value object.
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
#alpha ⇒ Integer
Returns 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_modulation ⇒ Float
Returns 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_offset ⇒ Float
Returns 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
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 |
#tint ⇒ nil, Float
Returns 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 |