Class: DynamicPDFApi::HtmlResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/ruby_client/HtmlResource.rb

Overview

Represents a pdf resource.

Instance Attribute Summary

Attributes inherited from Resource

#_file_path, #_mime_type, #data, #resource_name

Instance Method Summary collapse

Methods inherited from Resource

#_file_extension, _get_file_data

Constructor Details

#initialize(html, resourceName = nil) ⇒ HtmlResource

Initializes a new instance of the HtmlResource class.

Parameters:

  • name= ("html")

    The input html string.

  • name= ("resourceName")

    The name of the resource.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ruby_client/HtmlResource.rb', line 12

def initialize(html, resourceName = nil)
  @_file_extension = ".html"
  @_mime_type = "text/html"

  @data = html

  @resource_name = if resource_name.nil?
      SecureRandom.uuid + @_file_extension
    else
      resource_name
    end
  _type = ResourceType::HTML
end

Instance Method Details

#to_json(_options = {}) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/ruby_client/HtmlResource.rb', line 26

def to_json(_options = {})
  json_array = {}
  json_array["type"] = "html"

  json_array["resourceName"] = @resource_name
  JSON.pretty_generate(json_array)
end