Class: DynamicPDFApi::FontResource
- Defined in:
- lib/ruby_client/FontResource.rb
Instance Attribute Summary
Attributes inherited from Resource
#_file_path, #_mime_type, #data, #resource_name
Instance Method Summary collapse
- #_file_extension ⇒ Object
-
#initialize(file, resource_name = nil) ⇒ FontResource
constructor
A new instance of FontResource.
- #to_json(_options = {}) ⇒ Object
Methods inherited from Resource
Constructor Details
#initialize(file, resource_name = nil) ⇒ FontResource
Returns a new instance of FontResource.
6 7 8 9 10 |
# File 'lib/ruby_client/FontResource.rb', line 6 def initialize(file, resource_name = nil) @_mime_type = nil @_type = ResourceType::FONT super(file, resource_name) end |
Instance Method Details
#_file_extension ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby_client/FontResource.rb', line 12 def _file_extension file_header = @data[0, 4] byte_array = file_header.bytes if byte_array[0] == 0x4f && byte_array[1] == 0x54 && byte_array[2] == 0x54 && byte_array[3] == 0x4f @_mime_type = 'font/otf' '.otf' elsif byte_array[0] == 0x00 && byte_array[1] == 0x01 && byte_array[2] == 0x00 && byte_array[3] == 0x00 @_mime_type = 'font/ttf' '.ttf' else raise 'Unsupported font' end end |
#to_json(_options = {}) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/ruby_client/FontResource.rb', line 27 def to_json( = {}) json_array = {} json_array['name'] = @name json_array['resourceName'] = @resource_name JSON.pretty_generate(@json_array) end |