Class: BiDiGenerate::Command Private
- Inherits:
-
Struct
- Object
- Struct
- BiDiGenerate::Command
- Defined in:
- rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
params_class is the Parameters class the named args construct (nil for a no-arg
command); union_params picks its variant via .build rather than .new. result_ref
is the Protocol-relative result class path, or nil to return the raw hash.
Instance Attribute Summary collapse
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#params ⇒ Object
Returns the value of attribute params.
-
#params_class ⇒ Object
Returns the value of attribute params_class.
-
#result_ref ⇒ Object
Returns the value of attribute result_ref.
-
#spec_href ⇒ Object
Returns the value of attribute spec_href.
-
#union_params ⇒ Object
Returns the value of attribute union_params.
-
#wire_name ⇒ Object
Returns the value of attribute wire_name.
Instance Method Summary collapse
-
#def_header(indent) ⇒ Object
private
def nameordef name(...)— wrapped one argument per line when the signature would exceed the line limit. - #enum_checks(indent) ⇒ Object private
-
#execute_call(indent) ⇒ Object
private
@transport.execute(cmd:[, params: params][, result:]). - #optional_params ⇒ Object private
-
#params_assignment(indent) ⇒ Object
private
The
params = …line built before the execute call, or nil for a no-arg command. - #rbs_params ⇒ Object private
- #rbs_return ⇒ Object private
-
#rbs_signature ⇒ Object
private
The RBS method signature
(params) -> return— the return is the typed result class when the command parses one, elseuntyped. -
#render_lines(indent) ⇒ Object
private
The full
def … endblock, shared by the module template and a vendor variant that adds the command (VendorModule#render), so both render a command identically. - #required_params ⇒ Object private
Instance Attribute Details
#method_name ⇒ Object
Returns the value of attribute method_name
189 190 191 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 189 def method_name @method_name end |
#params ⇒ Object
Returns the value of attribute params
189 190 191 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 189 def params @params end |
#params_class ⇒ Object
Returns the value of attribute params_class
189 190 191 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 189 def params_class @params_class end |
#result_ref ⇒ Object
Returns the value of attribute result_ref
189 190 191 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 189 def result_ref @result_ref end |
#spec_href ⇒ Object
Returns the value of attribute spec_href
189 190 191 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 189 def spec_href @spec_href end |
#union_params ⇒ Object
Returns the value of attribute union_params
189 190 191 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 189 def union_params @union_params end |
#wire_name ⇒ Object
Returns the value of attribute wire_name
189 190 191 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 189 def wire_name @wire_name end |
Instance Method Details
#def_header(indent) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
def name or def name(...) — wrapped one argument per line when the signature
would exceed the line limit.
197 198 199 200 201 202 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 197 def def_header(indent) return "def #{method_name}" if params.empty? BiDiGenerate.wrap_call("def #{method_name}", required_params.map(&:sig_part) + optional_params.map(&:sig_part), indent) end |
#enum_checks(indent) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
193 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 193 def enum_checks(indent) = params.filter_map { |p| p.enum_check(indent) } |
#execute_call(indent) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
@transport.execute(cmd:[, params: params][, result:]). The result type is
referenced directly (resolved lazily in the method body, and unambiguous within
Protocol). Params, when present, are the params local built above.
232 233 234 235 236 237 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 232 def execute_call(indent) args = ["cmd: '#{wire_name}'"] args << 'params: params' unless params.empty? args << "result: #{result_ref}" if result_ref BiDiGenerate.wrap_call('execute', args, indent) end |
#optional_params ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
192 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 192 def optional_params = params.reject(&:required) |
#params_assignment(indent) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The params = … line built before the execute call, or nil for a no-arg command. A
record builds its Parameters object and a union dispatches via .build (whose typed
as_json emits explicit null where a flat hash through Transport could not). Wrapped
one entry per line when long, so it (and the short execute call) stay within the limit.
222 223 224 225 226 227 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 222 def params_assignment(indent) return nil if params.empty? kwargs = params.map { |p| "#{p.ruby_name}: #{p.ruby_name}" } BiDiGenerate.wrap_call("params = #{params_class}.#{union_params ? 'build' : 'new'}", kwargs, indent) end |
#rbs_params ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
210 211 212 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 210 def rbs_params (required_params.map(&:rbs_part) + optional_params.map(&:rbs_part)).join(', ') end |
#rbs_return ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
214 215 216 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 214 def rbs_return result_ref ? "::Selenium::WebDriver::BiDi::Protocol::#{result_ref}" : 'untyped' end |
#rbs_signature ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The RBS method signature (params) -> return — the return is the typed result class
when the command parses one, else untyped.
206 207 208 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 206 def rbs_signature "(#{rbs_params}) -> #{rbs_return}" end |
#render_lines(indent) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The full def … end block, shared by the module template and a vendor variant that adds
the command (VendorModule#render), so both render a command identically.
241 242 243 244 245 246 247 248 249 250 251 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 241 def render_lines(indent) pad = ' ' * indent body = ' ' * (indent + 2) lines = ["#{pad}# @api private", "#{pad}# @see #{BiDiGenerate::BIDI_DOC_URL}"] lines << "#{pad}# @see #{spec_href}" if spec_href lines << "#{pad}#{def_header(indent)}" lines.concat(enum_checks(indent + 2).map { |check| "#{body}#{check}" }) assignment = params_assignment(indent + 2) lines << "#{body}#{assignment}" if assignment lines + ["#{body}#{execute_call(indent + 2)}", "#{pad}end"] end |
#required_params ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
191 |
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 191 def required_params = params.select(&:required) |