Class: OoxmlParser::BordersProperties

Inherits:
OOXMLDocumentObject show all
Extended by:
Gem::Deprecate
Defined in:
lib/ooxml_parser/common_parser/common_data/borders_properties.rb

Overview

Border Properties Data

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(color = :auto, size = 0, val = :none, space = 0, parent: nil) ⇒ BordersProperties

Returns a new instance of BordersProperties.



10
11
12
13
14
15
16
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 10

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

Instance Attribute Details

#colorObject

Returns the value of attribute color.



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

def color
  @color
end

#frameObject

Returns the value of attribute frame.



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

def frame
  @frame
end

#shadowObject

Returns the value of attribute shadow.



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

def shadow
  @shadow
end

#sideObject

Returns the value of attribute side.



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

def side
  @side
end

#sizeOoxmlSize (readonly)

Returns size of border.

Returns:



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

def size
  @size
end

#spaceObject

Returns the value of attribute space.



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

def space
  @space
end

#valObject

Returns the value of attribute val.



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

def val
  @val
end

Instance Method Details

#copyBordersProperties

Method to copy object

Returns:



39
40
41
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 39

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

#nil?Boolean

Returns:

  • (Boolean)


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

def nil?
  size.zero? && val == :none
end

#parse(node) ⇒ BordersProperties

Parse BordersProperties

Parameters:

  • node (Nokogiri::XML:Element)

    with BordersProperties

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 52

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'val'
      @val = value.value.to_sym
    when 'sz'
      @size = 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
  return nil if @val == :nil

  self
end

#szOoxmlSize

Returns alias for sz.

Returns:



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

def sz
  size
end

#to_sString

Returns result of convert of object to string.

Returns:

  • (String)

    result of convert of object to string



31
32
33
34
35
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 31

def to_s
  return '' if nil?

  "borders color: #{@color}, size: #{size}, space: #{@space}, value: #{@val}"
end

#visible?Boolean

Returns:

  • (Boolean)


43
44
45
46
47
# File 'lib/ooxml_parser/common_parser/common_data/borders_properties.rb', line 43

def visible?
  return false if nil?

  val != 'none'
end