Class: Assently::Document
- Inherits:
-
Object
- Object
- Assently::Document
- Defined in:
- lib/assently/document.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #add_form_field(form_field) ⇒ Object
- #content_type ⇒ Object
- #data ⇒ Object
- #filename ⇒ Object
- #form_fields ⇒ Object
-
#initialize(path, filename: nil, username: nil, password: nil) ⇒ Document
constructor
A new instance of Document.
- #size ⇒ Object
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
#password ⇒ Object (readonly)
Returns the value of attribute password.
9 10 11 |
# File 'lib/assently/document.rb', line 9 def password @password end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/assently/document.rb', line 9 def path @path end |
#username ⇒ Object (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_type ⇒ Object
26 27 28 |
# File 'lib/assently/document.rb', line 26 def content_type "application/pdf" end |
#data ⇒ Object
30 31 32 |
# File 'lib/assently/document.rb', line 30 def data Base64.encode64 file_contents end |
#filename ⇒ Object
18 19 20 |
# File 'lib/assently/document.rb', line 18 def filename @filename || File.basename(path) end |
#form_fields ⇒ Object
38 39 40 |
# File 'lib/assently/document.rb', line 38 def form_fields @form_fields ||= [] end |
#size ⇒ Object
22 23 24 |
# File 'lib/assently/document.rb', line 22 def size file.size end |