Class: DynamicPDFApi::ExcelResource
- Defined in:
- lib/ruby_client/ExcelResource.rb
Overview
Represents a Excel resource.
Instance Attribute Summary collapse
-
#mime_type ⇒ Object
Returns the value of attribute mime_type.
Attributes inherited from Resource
#_file_path, #_mime_type, #data, #resource_name
Instance Method Summary collapse
- #file_extension=(value) ⇒ Object
-
#initialize(file, resourceName = nil) ⇒ ExcelResource
constructor
Initializes a new instance of the ExcelResource class.
-
#resource_name=(value) ⇒ Object
Sets the resource name.
- #SetMimeType ⇒ Object
- #to_json(_options = {}) ⇒ Object
Methods inherited from Resource
#_file_extension, _get_file_data
Constructor Details
#initialize(file, resourceName = nil) ⇒ ExcelResource
Initializes a new instance of the ExcelResource class.
13 14 15 16 17 18 19 20 21 |
# File 'lib/ruby_client/ExcelResource.rb', line 13 def initialize(file, resourceName = nil) @resource_name = nil @file_extension = nil super(file, resourceName) @_type = ResourceType::EXCEL @_mime_type = nil super(file, resource_name) end |
Instance Attribute Details
#mime_type ⇒ Object
Returns the value of attribute mime_type.
34 35 36 |
# File 'lib/ruby_client/ExcelResource.rb', line 34 def mime_type @mime_type end |
Instance Method Details
#file_extension=(value) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ruby_client/ExcelResource.rb', line 36 def file_extension=(value) @file_extension = value inputFileExtension = "" if (@resource_name != nil) if (File.extname(value) != nil) inputFileExtension = File.extname(value).ToLower else raise "Invalid resource name." end elsif (FilePath != nil) if (File.extname(FilePath) != nil) inputFileExtension = File.extname(FilePath).ToLower else raise "Invalid file path specified." end else raise "Invalid file path or resource name." end if (inputFileExtension == ".xls") @mime_type = "application/vnd.ms-excel" ".xls" elsif (inputFileExtension == ".xlsx" && @data[0] == 0x50 && @data[1] == 0x4b) @mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ".xlsx" else raise "Unsupported file type or invalid file extension." end end |
#resource_name=(value) ⇒ Object
Sets the resource name.
27 28 29 30 31 32 |
# File 'lib/ruby_client/ExcelResource.rb', line 27 def resource_name=(value) @resource_name = value if (value == nil || File.extname(value) == nil) raise "Invalid resource name." end end |
#SetMimeType ⇒ Object
66 67 68 69 |
# File 'lib/ruby_client/ExcelResource.rb', line 66 def SetMimeType() # _ = FileExtension end |
#to_json(_options = {}) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/ruby_client/ExcelResource.rb', line 71 def to_json( = {}) json_array = {} json_array["type"] = "excel" json_array["resourceName"] = @resource_name JSON.pretty_generate(json_array) end |