Class: OoxmlParser::OoxmlColor
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::OoxmlColor
- Defined in:
- lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb
Overview
Class for parsing ‘color` tag
Instance Attribute Summary collapse
-
#indexed ⇒ Float
readonly
Indexed id.
-
#rgb ⇒ Color
readonly
Rgb color.
-
#theme ⇒ Integer
readonly
Theme index.
-
#theme_color ⇒ Symbol
readonly
Theme color name.
-
#theme_shade ⇒ Symbol
readonly
Theme shade.
-
#theme_tint ⇒ Float
readonly
Theme tint.
-
#tint ⇒ Float
readonly
Tint.
-
#value ⇒ Color
readonly
Value of color.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#==(other) ⇒ True, False
Compare this object to other.
-
#parse(node) ⇒ OoxmlColor
Parse OoxmlColor object.
-
#to_color ⇒ Object
Convert OoxmlColor to other color type.
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
#indexed ⇒ Float (readonly)
Returns Indexed id.
19 20 21 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 19 def indexed @indexed end |
#rgb ⇒ Color (readonly)
Returns rgb color.
21 22 23 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 21 def rgb @rgb end |
#theme ⇒ Integer (readonly)
Returns theme index.
13 14 15 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 13 def theme @theme end |
#theme_color ⇒ Symbol (readonly)
Returns theme color name.
9 10 11 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 9 def theme_color @theme_color end |
#theme_shade ⇒ Symbol (readonly)
Returns theme shade.
11 12 13 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 11 def theme_shade @theme_shade end |
#theme_tint ⇒ Float (readonly)
Returns theme tint.
15 16 17 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 15 def theme_tint @theme_tint end |
#tint ⇒ Float (readonly)
Returns tint.
17 18 19 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 17 def tint @tint end |
#value ⇒ Color (readonly)
Returns value of color.
7 8 9 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 7 def value @value end |
Instance Method Details
#==(other) ⇒ True, False
Compare this object to other
36 37 38 39 40 41 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 36 def ==(other) return to_color == other if other.is_a?(Color) return to_color == other if other.is_a?(Symbol) super end |
#parse(node) ⇒ OoxmlColor
Parse OoxmlColor object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 46 def parse(node) node.attributes.each do |key, value| case key when 'val' @value = Color.new.parse_hex_string(value.value.to_s) when 'themeColor' @theme_color = value.value.to_sym when 'themeShade' @theme_shade = Integer("0x#{value.value}") when 'theme' @theme = value.value.to_i when 'tint' @tint = value.value.to_f when 'indexed' @indexed = value.value.to_i when 'rgb' @rgb = Color.new.parse_hex_string(value.value) when 'themeTint' @theme_tint = value.value.hex.to_f end end self end |
#to_color ⇒ Object
Convert OoxmlColor to other color type
25 26 27 28 29 30 31 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 25 def to_color return Color.get_rgb_by_color_index(indexed) if indexed return ThemeColors.new(parent: self).parse_color_theme(theme, tint) if theme return rgb if rgb value end |