Class: OoxmlParser::BordersProperties

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

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(color = :auto, sz = 0, val = :none, space = 0, parent: nil) ⇒ BordersProperties

Returns a new instance of BordersProperties.



6
7
8
9
10
11
12
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 6

def initialize(color = :auto, sz = 0, val = :none, space = 0, parent: nil)
  @color = color
  @sz = sz
  @val = val
  @space = space
  @parent = parent
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 4

def color
  @color
end

#frameObject

Returns the value of attribute frame.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 4

def frame
  @frame
end

#shadowObject

Returns the value of attribute shadow.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 4

def shadow
  @shadow
end

#sideObject

Returns the value of attribute side.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 4

def side
  @side
end

#spaceObject

Returns the value of attribute space.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 4

def space
  @space
end

#szObject Also known as: size

Returns the value of attribute sz.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 4

def sz
  @sz
end

#valObject

Returns the value of attribute val.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 4

def val
  @val
end

Instance Method Details

#copyObject



25
26
27
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 25

def copy
  BordersProperties.new(@color, @sz, @val, @space)
end

#nil?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 16

def nil?
  @sz.zero? && val == :none
end

#parse(node) ⇒ BordersProperties

Parse BordersProperties

Parameters:

  • node (Nokogiri::XML:Element)

    with BordersProperties

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 37

def parse(node)
  return nil if node.attribute('val').value == 'nil'
  node.attributes.each do |key, value|
    case key
    when 'val'
      @val = value.value.to_sym
    when 'sz'
      @sz = OoxmlSize.new(value.value.to_f, :one_eighth_point)
    when 'space'
      @space = OoxmlSize.new(value.value.to_f, :point)
    when 'color'
      @color = value.value.to_s
      @color = Color.new(parent: self).parse_hex_string(@color) if @color != 'auto'
    when 'shadow'
      @shadow = value.value
    end
  end
  self
end

#to_sObject



20
21
22
23
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 20

def to_s
  return '' if nil?
  "borders color: #{@color}, size: #{@sz}, space: #{@space}, value: #{@val}"
end

#visible?Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 29

def visible?
  return false if nil?
  val != 'none'
end