Class: DynamicPDFApi::ImageElement
- Defined in:
- lib/ruby_client/Elements/ImageElement.rb
Overview
Represents an image element.
This class can be used to place images on a page.
Instance Attribute Summary collapse
-
#_resource_name ⇒ Object
Returns the value of attribute _resource_name.
-
#max_height ⇒ Object
Gets or sets the maximum height of the image.
-
#max_width ⇒ Object
Gets or sets the maximum width of the image.
-
#scale_x ⇒ Object
Gets or sets the horizontal scale of the image.
-
#scale_y ⇒ Object
Gets or sets the vertical scale of the image.
Attributes inherited from Element
#_input_value, #_resource, #_text_font, #_type, #even_pages, #odd_pages, #placement, #x_offset, #y_offset
Class Method Summary collapse
-
.create_image_element(resource_name, placement, x_offset = 0, y_offset = 0) ⇒ Object
Initializes a new instance of the ImageElement class.
Instance Method Summary collapse
-
#initialize(resource, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) ⇒ ImageElement
constructor
Initializes a new instance of the ImageElement class.
- #to_json(_options = {}) ⇒ Object
Constructor Details
#initialize(resource, placement = ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) ⇒ ImageElement
Initializes a new instance of the ImageElement class.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_client/Elements/ImageElement.rb', line 19 def initialize(resource, placement= ElementPlacement::TOP_LEFT, x_offset = 0, y_offset = 0) super() @_type = ElementType::IMAGE @_resource = nil @_resource_name = nil if resource.is_a?(String) @_resource_name = resource else # super() @_resource = resource @_resource_name = resource.resource_name end @placement = placement @x_offset = x_offset @y_offset = y_offset end |
Instance Attribute Details
#_resource_name ⇒ Object
Returns the value of attribute _resource_name.
57 58 59 |
# File 'lib/ruby_client/Elements/ImageElement.rb', line 57 def _resource_name @_resource_name end |
#max_height ⇒ Object
Gets or sets the maximum height of the image.
72 73 74 |
# File 'lib/ruby_client/Elements/ImageElement.rb', line 72 def max_height @max_height end |
#max_width ⇒ Object
Gets or sets the maximum width of the image.
77 78 79 |
# File 'lib/ruby_client/Elements/ImageElement.rb', line 77 def max_width @max_width end |
#scale_x ⇒ Object
Gets or sets the horizontal scale of the image.
62 63 64 |
# File 'lib/ruby_client/Elements/ImageElement.rb', line 62 def scale_x @scale_x end |
#scale_y ⇒ Object
Gets or sets the vertical scale of the image.
67 68 69 |
# File 'lib/ruby_client/Elements/ImageElement.rb', line 67 def scale_y @scale_y end |
Class Method Details
.create_image_element(resource_name, placement, x_offset = 0, y_offset = 0) ⇒ Object
Initializes a new instance of the ImageElement class.
48 49 50 51 52 53 54 55 |
# File 'lib/ruby_client/Elements/ImageElement.rb', line 48 def self.create_image_element(resource_name, placement, x_offset = 0, y_offset = 0) image_element = new ImageElement(nil, nil) image_element._resource_name = resource_name image_element.placement = placement image_element.x_offset = x_offset image_element.y_offset = y_offset image_element end |
Instance Method Details
#to_json(_options = {}) ⇒ Object
79 80 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 |
# File 'lib/ruby_client/Elements/ImageElement.rb', line 79 def to_json( = {}) json_array = {} json_array['type'] = 'image' json_array['resourceName'] = @_resource_name unless @_resource_name.nil? json_array['scaleX'] = @scale_x unless @scale_x.nil? json_array['scaleY'] = @scale_y unless @scale_y.nil? json_array['maxHeight'] = @max_height unless @max_height.nil? json_array['maxWidth'] = @max_width unless @max_width.nil? # --------------------------------- 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 |