Class: OoxmlParser::PresentationPattern

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb

Constant Summary

Constants inherited from OOXMLDocumentObject

OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file

Constructor Details

#initialize(preset = nil) ⇒ PresentationPattern

Returns a new instance of PresentationPattern.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb', line 5

def initialize(preset = nil)
  @preset = preset
end

Instance Attribute Details

#background_colorObject

Returns the value of attribute background_color.



3
4
5
# File 'lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb', line 3

def background_color
  @background_color
end

#foreground_colorObject

Returns the value of attribute foreground_color.



3
4
5
# File 'lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb', line 3

def foreground_color
  @foreground_color
end

#presetObject

Returns the value of attribute preset.



3
4
5
# File 'lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb', line 3

def preset
  @preset
end

Class Method Details

.parse(pattern_node) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ooxml_parser/common_parser/common_data/colors/presentation_fill/presentation_pattern.rb', line 9

def self.parse(pattern_node)
  pattern = PresentationPattern.new(pattern_node.attribute('prst').value.to_sym)
  pattern_node.xpath('*').each do |color_node|
    case color_node.name
    when 'fgClr'
      pattern.foreground_color = Color.parse_color(color_node.xpath('*').first)
    when 'bgClr'
      pattern.background_color = Color.parse_color(color_node.xpath('*').first)
    end
  end
  pattern
end