Class: BiDiGenerate::TypeClass Private

Inherits:
Struct
  • Object
show all
Defined in:
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.

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#discriminatorObject

Returns the value of attribute discriminator

Returns:

  • (Object)

    the current value of discriminator



274
275
276
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 274

def discriminator
  @discriminator
end

#extensibleObject

Returns the value of attribute extensible

Returns:

  • (Object)

    the current value of extensible



274
275
276
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 274

def extensible
  @extensible
end

#fieldsObject

Returns the value of attribute fields

Returns:

  • (Object)

    the current value of fields



274
275
276
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 274

def fields
  @fields
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



274
275
276
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 274

def label
  @label
end

#nestedObject

Returns the value of attribute nested

Returns:

  • (Object)

    the current value of nested



274
275
276
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 274

def nested
  @nested
end

#ownerObject

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



274
275
276
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 274

def owner
  @owner
end

#ruby_nameObject

Returns the value of attribute ruby_name

Returns:

  • (Object)

    the current value of ruby_name



274
275
276
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 274

def ruby_name
  @ruby_name
end

#schema_nameObject

Returns the value of attribute schema_name

Returns:

  • (Object)

    the current value of schema_name



274
275
276
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 274

def schema_name
  @schema_name
end

#syntheticObject

Returns the value of attribute synthetic

Returns:

  • (Object)

    the current value of synthetic



274
275
276
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 274

def synthetic
  @synthetic
end

Instance Method Details

#define_assignment(name, 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.

Name = Serialization::Record.define(...) as one line when it fits within the line limit at the given indent, else wrapped one entry per line — so the emitted source stays inside RuboCop's length limit without a per-file exception. Entries render at indent + 2, the indent a long field hash wraps itself against.



293
294
295
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 293

def define_assignment(name, indent)
  BiDiGenerate.wrap_call("#{name} = Serialization::Record.define", define_entries(indent + 2), indent)
end

#define_entries(entry_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.

Keyword arguments for Serialization::Record.define(...): the fixed discriminator member first, then the fields, then the extensible flag.



281
282
283
284
285
286
287
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 281

def define_entries(entry_indent)
  entries = []
  entries << discriminator_entry if discriminator
  entries.concat(fields.map { |f| f.spec_entry(entry_indent) })
  entries << 'extensible: true' if extensible
  entries
end

#discriminator_entryObject

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.



297
298
299
300
301
302
303
304
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 297

def discriminator_entry
  literal = BiDiGenerate.ruby_literal(discriminator[:value])
  if discriminator[:wire] == discriminator[:ruby_name].to_s
    "#{discriminator[:ruby_name]}: {fixed: #{literal}}"
  else
    "#{discriminator[:ruby_name]}: {wire_key: '#{discriminator[:wire]}', fixed: #{literal}}"
  end
end

#nested_typesObject

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.



277
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 277

def nested_types = nested || []

#rbs_new_argsObject

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 keyword arguments self.new accepts: each constructable field with its value type, plus the optional extensions bag. The fixed discriminator is baked, so its value is ignored — but the lenient **kwargs constructor still accepts it (and a command method passes it through), so it is advertised as an optional keyword typed to its const.



322
323
324
325
326
327
328
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 322

def rbs_new_args
  parts = []
  parts << "?#{discriminator[:ruby_name]}: #{discriminator[:rbs]}" if discriminator
  parts.concat(fields.map(&:rbs_arg))
  parts << '?extensions: untyped' if extensible
  parts.join(', ')
end

#rbs_readersObject

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.

Every Data member gets a typed attr_reader: the baked discriminator (typed to its const), each field (typed when required; UNSET-bearing optionals stay untyped), then the extensible passthrough.



309
310
311
312
313
314
315
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 309

def rbs_readers
  readers = []
  readers << "#{discriminator[:ruby_name]}: #{discriminator[:rbs]}" if discriminator
  readers.concat(fields.map(&:rbs_reader))
  readers << 'extensions: Hash[String, untyped]' if extensible
  readers
end

#union?Boolean

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.

Returns:

  • (Boolean)


276
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 276

def union? = false