class OoxmlParser::OoxmlColor
Class for parsing ‘color` tag
Attributes
indexed[R]
@return [Float] Indexed id
rgb[R]
@return [Color] rgb color
theme[R]
@return [Integer] theme index
theme_color[R]
@return [Symbol] theme color name
theme_shade[R]
@return [Symbol] theme shade
theme_tint[R]
@return [Float] theme tint
tint[R]
@return [Float] tint
value[R]
@return [Color] value of color
Public Instance Methods
==(other)
click to toggle source
Compare this object to other @param other [Object] any other object @return [True, False] result of comparision
Calls superclass method
# 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)
click to toggle source
Parse OoxmlColor
object @param node [Nokogiri::XML:Element] node to parse @return [OoxmlColor] result of parsing
# 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()
click to toggle source
Convert OoxmlColor
to other color type @return [Object] result of conversion
# 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