Class: DynamicPDFApi::Outline

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_client/Outline.rb

Overview

Represents an outline.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, action = nil) ⇒ Outline

Initializes a new instance of the Outline class.

Parameters:

  • input (PdfInput)

    The input of type PdfInput .

  • action (Action) (defaults to: nil)

    Action of the outline.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ruby_client/Outline.rb', line 18

def initialize(input, action = nil)
  @_color_name = nil
  @text = nil
  @style = nil
  @expanded = nil
  @children = nil
  @action = nil
  @_from_input_id = nil
  @color = nil

  @children = OutlineList.new
  if input.is_a?(String)
    @text = input
    @action = action
  else
    @_from_input_id = input.id
  end
end

Instance Attribute Details

#_color_nameObject

Returns the value of attribute _color_name.



37
38
39
# File 'lib/ruby_client/Outline.rb', line 37

def _color_name
  @_color_name
end

#_from_input_idObject

Returns the value of attribute _from_input_id.



37
38
39
# File 'lib/ruby_client/Outline.rb', line 37

def _from_input_id
  @_from_input_id
end

#actionObject

Gets or sets the Action of the outline.



61
62
63
# File 'lib/ruby_client/Outline.rb', line 61

def action
  @action
end

#childrenObject

Gets or sets a collection of child outlines.



57
58
59
# File 'lib/ruby_client/Outline.rb', line 57

def children
  @children
end

#colorObject

Gets or sets the color of the outline.



66
67
68
# File 'lib/ruby_client/Outline.rb', line 66

def color
  @color
end

#expandedObject

Gets or sets a value specifying if the outline is expanded.



52
53
54
# File 'lib/ruby_client/Outline.rb', line 52

def expanded
  @expanded
end

#styleObject

Gets or sets the style of the outline.



47
48
49
# File 'lib/ruby_client/Outline.rb', line 47

def style
  @style
end

#textObject

Gets or sets the text of the outline.



42
43
44
# File 'lib/ruby_client/Outline.rb', line 42

def text
  @text
end

Instance Method Details

#_get_childrenObject

Gets collection of child outlines.

Returns:

  • OutlineList Collection of child outlines.



73
74
75
76
77
78
79
# File 'lib/ruby_client/Outline.rb', line 73

def _get_children
  if (@children != nil)
    @children&._out_lines
  else
    nil
  end
end

#to_json(_options = {}) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/ruby_client/Outline.rb', line 81

def to_json(_options = {})
  json_array = {}

  json_array["type"] = "Outline"

  unless @color.nil?
    color_string = @color._color_string
    json_array['color'] = color_string unless color_string.nil?
  end

  json_array["text"] = @text unless @text.nil?

  json_array["linkTo"] = @action unless @action.nil?

  json_array["style"] = @style unless @style.nil?

  json_array["expanded"] = @expanded unless @expanded.nil?

  if !@children.nil? && !@children._out_lines.empty?
    children_array = []
    (0..(@children._out_lines.length - 1)).each do |i|
      children_array << @children._out_lines[i] unless @children._out_lines[i].nil?
    end
    json_array["children"] = children_array
  end
  json_array["fromInputID"] = @_from_input_id unless @_from_input_id.nil?

  JSON.pretty_generate(json_array)
end