Class: Browserless::Client
- Inherits:
-
Object
- Object
- Browserless::Client
- Defined in:
- lib/browserless/client.rb
Instance Attribute Summary collapse
-
#emulate_media ⇒ Object
readonly
Returns the value of attribute emulate_media.
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#style_tag ⇒ Object
readonly
Returns the value of attribute style_tag.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(html:, options: {}, **kwargs) ⇒ Client
constructor
A new instance of Client.
- #to_pdf ⇒ Object
Constructor Details
#initialize(html:, options: {}, **kwargs) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 |
# File 'lib/browserless/client.rb', line 12 def initialize(html:, options: {}, **kwargs) @html = html @options = Options.new(**).to_h @style_tag = StyleTag.new(kwargs[:style_tag]).to_h @emulate_media = config_value(:emulate_media, kwargs[:emulate_media]) || "screen" @url = Browserless.configuration.url end |
Instance Attribute Details
#emulate_media ⇒ Object (readonly)
Returns the value of attribute emulate_media.
10 11 12 |
# File 'lib/browserless/client.rb', line 10 def emulate_media @emulate_media end |
#html ⇒ Object (readonly)
Returns the value of attribute html.
10 11 12 |
# File 'lib/browserless/client.rb', line 10 def html @html end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/browserless/client.rb', line 10 def @options end |
#style_tag ⇒ Object (readonly)
Returns the value of attribute style_tag.
10 11 12 |
# File 'lib/browserless/client.rb', line 10 def style_tag @style_tag end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/browserless/client.rb', line 10 def url @url end |
Class Method Details
.headers ⇒ Object
79 80 81 82 83 84 |
# File 'lib/browserless/client.rb', line 79 def headers { "Cache-Control": "no-cache", "Content-Type": "application/json" } end |
Instance Method Details
#to_pdf ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/browserless/client.rb', line 20 def to_pdf temp_file = Tempfile.new save_pdf_to_temp_file(temp_file) temp_file.read ensure temp_file.close temp_file.unlink end |