Class: DynamicPDFApi::LineElement

Inherits:
Element
  • Object
show all
Defined in:
lib/ruby_client/Elements/LineElement.rb

Overview

Represents a line page element.

This class can be used to place lines of different length, width, color and patterns on a page.

Instance Attribute Summary collapse

Attributes inherited from Element

#_input_value, #_resource, #_text_font, #_type, #even_pages, #odd_pages, #placement, #x_offset, #y_offset

Instance Method Summary collapse

Constructor Details

#initialize(x2_offset, y2_offset, placement = ElementPlacement::TOP_LEFT) ⇒ LineElement

Initializes a new instance of the LineElement class.

Parameters:

  • placement (String) (defaults to: ElementPlacement::TOP_LEFT)

    The placement of the line on the page.

  • x2_offset (float)

    X2 coordinate of the line.

  • y2_offset (float)

    Y2 coordinate of the line.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruby_client/Elements/LineElement.rb', line 19

def initialize(x2_offset, y2_offset, placement = ElementPlacement::TOP_LEFT)
  super()
  @color = nil
  @width = nil
  @line_style = nil
  @_type = ElementType::LINE

  @placement = placement
  @x2_offset = x2_offset
  @y2_offset = y2_offset
end

Instance Attribute Details

#colorObject

Gets or sets the Color object to use for the line.



34
35
36
# File 'lib/ruby_client/Elements/LineElement.rb', line 34

def color
  @color
end

#line_styleObject

Gets or sets the LineStyle object to use for the style of the line.



54
55
56
# File 'lib/ruby_client/Elements/LineElement.rb', line 54

def line_style
  @line_style
end

#widthObject

Gets or sets the width of the line.



49
50
51
# File 'lib/ruby_client/Elements/LineElement.rb', line 49

def width
  @width
end

#x2_offsetObject

Gets or sets the X2 coordinate of the line.



39
40
41
# File 'lib/ruby_client/Elements/LineElement.rb', line 39

def x2_offset
  @x2_offset
end

#y2_offsetObject

Gets or sets the Y2 coordinate of the line.



44
45
46
# File 'lib/ruby_client/Elements/LineElement.rb', line 44

def y2_offset
  @y2_offset
end

Instance Method Details

#to_json(_options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/ruby_client/Elements/LineElement.rb', line 56

def to_json(_options = {})
  json_array = {}
  json_array["type"] = "line"

  json_array["color"] = @color._color_string if !@color.nil? && !@color._color_string.nil?

  json_array["xOffset"] = @x_offset unless @x_offset.nil?

  json_array["yOffset"] = @y_offset unless @y_offset.nil?

  json_array["x2Offset"] = @x2_offset unless @x2_offset.nil?

  json_array["y2Offset"] = @y2_offset unless @y2_offset.nil?

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

  if !@line_style.nil? && !@line_style._line_style_string.nil?
    json_array["lineStyle"] =
      @line_style._line_style_string
  end

  # ---------------------------------

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

  json_array["xOffset"] = @x_offset unless @x_offset.nil?

  json_array["yOffset"] = @y_offset unless @y_offset.nil?

  json_array["evenPages"] = @even_pages unless @even_pages.nil?

  json_array["oddPages"] = @odd_pages unless @odd_pages.nil?

  JSON.pretty_generate(json_array)
end