Class: Assently::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/assently/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, filename: nil, username: nil, password: nil) ⇒ Document

Returns a new instance of Document.



11
12
13
14
15
16
# File 'lib/assently/document.rb', line 11

def initialize path, filename: nil, username: nil, password: nil
  @path = path
  @filename = filename
  @username = username
  @password = password
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



9
10
11
# File 'lib/assently/document.rb', line 9

def password
  @password
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/assently/document.rb', line 9

def path
  @path
end

#usernameObject (readonly)

Returns the value of attribute username.



9
10
11
# File 'lib/assently/document.rb', line 9

def username
  @username
end

Instance Method Details

#add_form_field(form_field) ⇒ Object



34
35
36
# File 'lib/assently/document.rb', line 34

def add_form_field form_field
  self.form_fields << form_field
end

#content_typeObject



26
27
28
# File 'lib/assently/document.rb', line 26

def content_type
  "application/pdf"
end

#dataObject



30
31
32
# File 'lib/assently/document.rb', line 30

def data
  Base64.encode64 file_contents
end

#filenameObject



18
19
20
# File 'lib/assently/document.rb', line 18

def filename
  @filename || File.basename(path)
end

#form_fieldsObject



38
39
40
# File 'lib/assently/document.rb', line 38

def form_fields
  @form_fields ||= []
end

#sizeObject



22
23
24
# File 'lib/assently/document.rb', line 22

def size
  file.size
end