Module: Ilovepdf::Signature::FileElement::InstanceMethods

Defined in:
lib/ilovepdf/signature/file_element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



9
10
11
# File 'lib/ilovepdf/signature/file_element.rb', line 9

def content
  @content
end

#fileObject (readonly)

Returns the value of attribute file.



9
10
11
# File 'lib/ilovepdf/signature/file_element.rb', line 9

def file
  @file
end

#infoObject (readonly)

Returns the value of attribute info.



9
10
11
# File 'lib/ilovepdf/signature/file_element.rb', line 9

def info
  @info
end

#pagesObject

Returns the value of attribute pages.



9
10
11
# File 'lib/ilovepdf/signature/file_element.rb', line 9

def pages
  @pages
end

#positionObject (readonly)

Returns the value of attribute position.



9
10
11
# File 'lib/ilovepdf/signature/file_element.rb', line 9

def position
  @position
end

#sizeObject

Returns the value of attribute size.



9
10
11
# File 'lib/ilovepdf/signature/file_element.rb', line 9

def size
  @size
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/ilovepdf/signature/file_element.rb', line 9

def type
  @type
end

Instance Method Details

#initialize(file) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/ilovepdf/signature/file_element.rb', line 10

def initialize(file)
  raise ::Ilovepdf::Errors::ArgumentError.new("Only Ilovepdf::File type of object is allowed") unless file.class.name == "Ilovepdf::File"
  @file = file
  @position = "0 0"
  @pages = "1"
  @size = 40
end

#set_position(x: 0, y: 0) ⇒ Object



18
19
20
21
22
23
# File 'lib/ilovepdf/signature/file_element.rb', line 18

def set_position(x: 0,y: 0)
  raise ::Ilovepdf::Errors::ArgumentError.new("x must be an integer or float") unless x.is_a?(Integer) || x.is_a?(Float)
  raise ::Ilovepdf::Errors::ArgumentError.new("y must be an integer or float") unless y.is_a?(Integer) || y.is_a?(Float)
  @position = "#{x.abs} #{-y.abs}"
  position
end

#to_hObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/ilovepdf/signature/file_element.rb', line 35

def to_h
  {
    position: position,
    pages: pages,
    size: size,
    info: info,
    type: type,
    content: content
  }
end