Class: OoxmlParser::ThemeColor

Inherits:
Object
  • Object
show all
Defined in:
lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = '', color = nil) ⇒ ThemeColor

Returns a new instance of ThemeColor.



5
6
7
8
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb', line 5

def initialize(type = '', color = nil)
  @type = type
  @color = color
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



3
4
5
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb', line 3

def color
  @color
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb', line 3

def type
  @type
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb', line 3

def value
  @value
end

Class Method Details

.parse(color_node) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb', line 24

def self.parse(color_node)
  theme_color = ThemeColor.new
  color_node.xpath('*').each do |color_node_child|
    case color_node_child.name
    when 'sysClr'
      theme_color.type = :system
      theme_color.value = color_node_child.attribute('val').value
      theme_color.color = Color.from_int16(color_node_child.attribute('lastClr').value.to_s) unless color_node_child.attribute('lastClr').nil?
    when 'srgbClr'
      theme_color.type = :rgb
      theme_color.color = Color.from_int16(color_node_child.attribute('val').value.to_s)
    end
  end
  theme_color
end

Instance Method Details

#==(other) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/presentation_theme/theme_color.rb', line 10

def ==(other)
  if other.is_a?(Color)
    @color == other
  else
    all_instance_variables = instance_variables
    all_instance_variables.each do |current_attributes|
      unless instance_variable_get(current_attributes) == other.instance_variable_get(current_attributes)
        return false
      end
    end
    true
  end
end