Class: DynamicPDFApi::WordResource
- Defined in:
- lib/ruby_client/WordResource.rb
Overview
Represents a Word 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) ⇒ WordResource
constructor
Initializes a new instance of the WordResource 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) ⇒ WordResource
Initializes a new instance of the WordResource class.
13 14 15 16 17 18 19 20 21 |
# File 'lib/ruby_client/WordResource.rb', line 13 def initialize(file, resourceName = nil) @resource_name = nil @file_extension = nil super(file, resourceName) @_type = ResourceType::WORD @_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/WordResource.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 65 66 67 |
# File 'lib/ruby_client/WordResource.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 == ".doc") @mime_type = "application/msword" ".doc" elsif (inputFileExtension == ".docx" && @data[0] == 0x50 && @data[1] == 0x4b) @mime_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ".docx" elsif (inputFileExtension == ".odt" && @data[0] == 0x50 && @data[1] == 0x4b) @mime_type = "application/vnd.oasis.opendocument.text" ".odt" 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/WordResource.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
69 70 71 72 |
# File 'lib/ruby_client/WordResource.rb', line 69 def SetMimeType() # _ = FileExtension end |
#to_json(_options = {}) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/ruby_client/WordResource.rb', line 74 def to_json( = {}) json_array = {} json_array["type"] = "word" json_array["resourceName"] = @resource_name JSON.pretty_generate(json_array) end |