Class: OoxmlParser::PresentationFill

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

Constant Summary

Constants inherited from OOXMLDocumentObject

OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA

Instance Attribute Summary collapse

Class 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

Instance Attribute Details

#colorObject

Returns the value of attribute color.



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

def color
  @color
end

#imageObject

Returns the value of attribute image.



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

def image
  @image
end

#patternObject

Returns the value of attribute pattern.



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

def pattern
  @pattern
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Class Method Details

.parse(parent_fill_node) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ooxml_parser/common_parser/common_data/colors/presentation_fill.rb', line 8

def self.parse(parent_fill_node)
  fill = PresentationFill.new
  return nil if parent_fill_node.xpath('*').empty?
  parent_fill_node.xpath('*').each do |fill_node|
    case fill_node.name
    when 'gradFill'
      fill.type = :gradient
      fill.color = GradientColor.parse(fill_node)
    when 'solidFill'
      fill.type = :solid
      fill.color = Color.parse_color(fill_node.xpath('*').first)
    when 'blipFill'
      fill.type = :image
      fill.image = ImageFill.parse(fill_node)
    when 'pattFill'
      fill.type = :pattern
      fill.pattern = PresentationPattern.parse(fill_node)
    when 'noFill'
      fill.type = :noneColor
      fill.color = :none
    end
  end
  fill
end