Class: Puppeteer::Bidi::Dialog
- Inherits:
-
Object
- Object
- Puppeteer::Bidi::Dialog
- Defined in:
- lib/puppeteer/bidi/dialog.rb,
sig/puppeteer/bidi/dialog.rbs
Overview
Dialog instances are dispatched by Page via the :dialog event.
Instance Attribute Summary collapse
- #default_value ⇒ String readonly
- #message ⇒ String readonly
- #type ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
- #accept(prompt_text = nil) ⇒ void
- #dismiss ⇒ void
- #handle(accept:, text: nil) ⇒ void
- #handled? ⇒ Boolean
-
#initialize(prompt) ⇒ Dialog
constructor
A new instance of Dialog.
Constructor Details
#initialize(prompt) ⇒ Dialog
Returns a new instance of Dialog.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/puppeteer/bidi/dialog.rb', line 20 def initialize(prompt) @prompt = prompt @type = prompt.info["type"] @message = prompt.info["message"] @default_value = prompt.info.fetch("defaultValue", "") @handled = prompt.handled? prompt.once(:handled) do @handled = true end end |
Instance Attribute Details
#default_value ⇒ String (readonly)
10 11 12 |
# File 'lib/puppeteer/bidi/dialog.rb', line 10 def default_value @default_value end |
#message ⇒ String (readonly)
9 10 11 |
# File 'lib/puppeteer/bidi/dialog.rb', line 9 def @message end |
#type ⇒ String (readonly)
8 9 10 |
# File 'lib/puppeteer/bidi/dialog.rb', line 8 def type @type end |
Class Method Details
.from(prompt) ⇒ Dialog
14 15 16 |
# File 'lib/puppeteer/bidi/dialog.rb', line 14 def self.from(prompt) new(prompt) end |
Instance Method Details
#accept(prompt_text = nil) ⇒ void
This method returns an undefined value.
39 40 41 42 43 44 |
# File 'lib/puppeteer/bidi/dialog.rb', line 39 def accept(prompt_text = nil) raise Error, "Cannot accept dialog which is already handled!" if handled? @handled = true handle(accept: true, text: prompt_text) end |
#dismiss ⇒ void
This method returns an undefined value.
47 48 49 50 51 52 |
# File 'lib/puppeteer/bidi/dialog.rb', line 47 def dismiss raise Error, "Cannot dismiss dialog which is already handled!" if handled? @handled = true handle(accept: false) end |
#handle(accept:, text: nil) ⇒ void
This method returns an undefined value.
59 60 61 62 |
# File 'lib/puppeteer/bidi/dialog.rb', line 59 def handle(accept:, text: nil) @prompt.handle(accept: accept, user_text: text).wait nil end |
#handled? ⇒ Boolean
33 34 35 |
# File 'lib/puppeteer/bidi/dialog.rb', line 33 def handled? @handled end |