Class: OoxmlParser::Shade

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb

Overview

Class for parsing ‘w:shd` object

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(value: nil, color: nil, fill: nil, parent: nil) ⇒ Shade

Returns a new instance of Shade.



11
12
13
14
15
16
17
18
19
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 11

def initialize(value: nil,
               color: nil,
               fill: nil,
               parent: nil)
  @value = value
  @color = color
  @fill = fill
  @parent = parent
end

Instance Attribute Details

#colorSymbol

Returns color of shade.

Returns:

  • (Symbol)

    color of shade



7
8
9
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 7

def color
  @color
end

#fillColor

Returns fill of shade.

Returns:

  • (Color)

    fill of shade



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 9

def fill
  @fill
end

#valueSymbol

Returns value of shade.

Returns:

  • (Symbol)

    value of shade



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 5

def value
  @value
end

Instance Method Details

#parse(node) ⇒ Shade

Parse Shade

Parameters:

  • node (Nokogiri::XML:Node)

    with Shade

Returns:

  • (Shade)

    result of parsing



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_run/run_properties/shade.rb', line 24

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'val'
      @value = value.value.to_sym
    when 'color'
      @color = value.value.to_sym
    when 'fill'
      @fill = Color.new(parent: self).parse_hex_string(value.value.to_s)
    end
  end
  self
end