Class: Egree::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/egree/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.



10
11
12
13
14
15
# File 'lib/egree/document.rb', line 10

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.



8
9
10
# File 'lib/egree/document.rb', line 8

def password
  @password
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/egree/document.rb', line 8

def path
  @path
end

#usernameObject (readonly)

Returns the value of attribute username.



8
9
10
# File 'lib/egree/document.rb', line 8

def username
  @username
end

Instance Method Details

#add_form_field(form_field) ⇒ Object



33
34
35
# File 'lib/egree/document.rb', line 33

def add_form_field form_field
  self.form_fields << form_field
end

#content_typeObject



25
26
27
# File 'lib/egree/document.rb', line 25

def content_type
  "application/pdf"
end

#dataObject



29
30
31
# File 'lib/egree/document.rb', line 29

def data
  Base64.encode64 file_contents
end

#filenameObject



17
18
19
# File 'lib/egree/document.rb', line 17

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

#form_fieldsObject



37
38
39
# File 'lib/egree/document.rb', line 37

def form_fields
  @form_fields ||= []
end

#sizeObject



21
22
23
# File 'lib/egree/document.rb', line 21

def size
  file.size
end