Class: DynamicPDFApi::ImageInput

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

Overview

Represents an image input.

Instance Attribute Summary collapse

Attributes inherited from Input

#_resources, #_template_id, #id, #resource_name

Instance Method Summary collapse

Methods inherited from Input

#get_template, #set_template

Constructor Details

#initialize(resource) ⇒ ImageInput

Initializes a new instance of the ImageInput class.

Parameters:

  • resource (String)

    |[ImageResource] The image file path present in cloud resource manager or the ImageResource object to create ImageInput.



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

def initialize(resource)
  @_type = InputType::IMAGE
  @scale_x = nil
  @scale_y = nil
  @top_margin = nil
  @left_margin = nil
  @bottom_margin = nil
  @right_margin = nil
  @page_width = nil
  @page_height = nil
  @expand_to_fit = nil
  @shrink_to_fit = nil
  @align = Align::CENTER
  @v_align = VAlign::CENTER
  @start_page = nil
  @page_count = nil
  super(resource)
end

Instance Attribute Details

#_typeObject

Returns the value of attribute _type.



36
37
38
# File 'lib/ruby_client/ImageInput.rb', line 36

def _type
  @_type
end

#alignObject

Gets or sets the horizontal alignment of the image.



90
91
92
# File 'lib/ruby_client/ImageInput.rb', line 90

def align
  @align
end

#bottom_marginObject

Gets or sets the bottom margin.



60
61
62
# File 'lib/ruby_client/ImageInput.rb', line 60

def bottom_margin
  @bottom_margin
end

#expand_to_fitObject

Gets or sets a boolean indicating whether to expand the image.



80
81
82
# File 'lib/ruby_client/ImageInput.rb', line 80

def expand_to_fit
  @expand_to_fit
end

#left_marginObject

Gets or sets the left margin.



55
56
57
# File 'lib/ruby_client/ImageInput.rb', line 55

def left_margin
  @left_margin
end

#page_countObject

Gets or sets the page count.



105
106
107
# File 'lib/ruby_client/ImageInput.rb', line 105

def page_count
  @page_count
end

#page_heightObject

Gets or sets the page height.



75
76
77
# File 'lib/ruby_client/ImageInput.rb', line 75

def page_height
  @page_height
end

#page_widthObject

Gets or sets the page width.



70
71
72
# File 'lib/ruby_client/ImageInput.rb', line 70

def page_width
  @page_width
end

#right_marginObject

Gets or sets the right margin.



65
66
67
# File 'lib/ruby_client/ImageInput.rb', line 65

def right_margin
  @right_margin
end

#scale_xObject

Gets or sets the scaleX of the image.



41
42
43
# File 'lib/ruby_client/ImageInput.rb', line 41

def scale_x
  @scale_x
end

#scale_yObject

Gets or sets the scaleY of the image.



46
47
48
# File 'lib/ruby_client/ImageInput.rb', line 46

def scale_y
  @scale_y
end

#shrink_to_fitObject

Gets or sets a boolean indicating whether to shrink the image.



85
86
87
# File 'lib/ruby_client/ImageInput.rb', line 85

def shrink_to_fit
  @shrink_to_fit
end

#start_pageObject

Gets or sets the start page.



100
101
102
# File 'lib/ruby_client/ImageInput.rb', line 100

def start_page
  @start_page
end

#top_marginObject

Gets or sets the top margin.



50
51
52
# File 'lib/ruby_client/ImageInput.rb', line 50

def top_margin
  @top_margin
end

#v_alignObject

Gets or sets the vertical alignment of the image.



95
96
97
# File 'lib/ruby_client/ImageInput.rb', line 95

def v_align
  @v_align
end

Instance Method Details

#to_json(_options = {}) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/ruby_client/ImageInput.rb', line 107

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

  json_array['type'] = 'image'

  json_array['scaleX'] = @scale_x unless @scale_x.nil?

  json_array['scaleY'] = @scale_y unless @scale_y.nil?

  json_array['topMargin'] = @top_margin unless @top_margin.nil?

  json_array['leftMargin'] = @left_margin unless @left_margin.nil?

  json_array['bottomMargin'] = @bottom_margin unless @bottom_margin.nil?

  json_array['rightMargin'] = @right_margin unless @right_margin.nil?

  json_array['pageWidth'] = @page_width unless @page_width.nil?

  json_array['pageHeight'] = @page_height unless @page_height.nil?

  json_array['expandToFit'] = @expand_to_fit unless @expand_to_fit.nil?

  json_array['shrinkToFit'] = @shrink_to_fit unless @shrink_to_fit.nil?

  json_array['align'] = @align unless @align.nil?

  json_array['vAlign'] = @a_align unless @a_align.nil?

  json_array['startPage'] = @start_page unless @start_page.nil?

  json_array['pageCount'] = @page_count unless @page_count.nil?

  #---------------------------------------------------
  json_array['templateId'] = @_template_id unless @_template_id.nil?

  json_array['resourceName'] = @resource_name unless @resource_name.nil?

  json_array['id'] = @id unless @id.nil?

  JSON.pretty_generate(json_array)
end