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.
-
#tint ⇒ Float
readonly
Tint.
-
#value ⇒ Color
readonly
Value of color.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#parse(node) ⇒ Hyperlink
Parse Hyperlink object.
- #to_color ⇒ Object
Methods inherited from OOXMLDocumentObject
add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, #initialize, unzip_file, #with_data?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
This class inherits a constructor from OoxmlParser::OOXMLDocumentObject
Instance Attribute Details
#indexed ⇒ Float (readonly)
Returns Indexed id.
15 16 17 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 15 def indexed @indexed end |
#rgb ⇒ Color (readonly)
Returns rgb color.
17 18 19 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 17 def rgb @rgb end |
#theme ⇒ Integer (readonly)
Returns theme index.
11 12 13 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 11 def theme @theme end |
#theme_color ⇒ Symbol (readonly)
Returns theme color name.
7 8 9 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 7 def theme_color @theme_color end |
#theme_shade ⇒ Symbol (readonly)
Returns theme shade.
9 10 11 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 9 def theme_shade @theme_shade end |
#tint ⇒ Float (readonly)
Returns tint.
13 14 15 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 13 def tint @tint end |
#value ⇒ Color (readonly)
Returns value of color.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 5 def value @value end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 29 30 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 26 def ==(other) return to_color == other if other.is_a?(Color) return to_color == other if other.is_a?(Symbol) super end |
#parse(node) ⇒ Hyperlink
Parse Hyperlink object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 35 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) end end self end |
#to_color ⇒ Object
19 20 21 22 23 24 |
# File 'lib/ooxml_parser/common_parser/common_data/color/ooxml_color.rb', line 19 def to_color return Color.get_rgb_by_color_index(indexed) if indexed return ThemeColors.parse_color_theme(theme, tint) if theme return rgb if rgb value end |