Class: BiDiGenerate::FieldIR 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.

ref is the Protocol-relative class path for a nested structured field (nil for a scalar/opaque field); list wraps it in an array. wire_key is the exact JSON payload key (the schema's wire name, baked verbatim).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bounds ⇒ Object

Returns the value of attribute bounds

Returns:

  • (Object) —

    the current value of bounds



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def bounds
  @bounds
end

#const ⇒ Object

Returns the value of attribute const

Returns:

  • (Object) —

    the current value of const



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def const
  @const
end

#enum ⇒ Object

Returns the value of attribute enum

Returns:

  • (Object) —

    the current value of enum



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def enum
  @enum
end

#list ⇒ Object

Returns the value of attribute list

Returns:

  • (Object) —

    the current value of list



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def list
  @list
end

#map_of ⇒ Object

Returns the value of attribute map_of

Returns:

  • (Object) —

    the current value of map_of



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def map_of
  @map_of
end

#nullable ⇒ Object

Returns the value of attribute nullable

Returns:

  • (Object) —

    the current value of nullable



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def nullable
  @nullable
end

#primitive ⇒ Object

Returns the value of attribute primitive

Returns:

  • (Object) —

    the current value of primitive



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def primitive
  @primitive
end

#rbs ⇒ Object

Returns the value of attribute rbs

Returns:

  • (Object) —

    the current value of rbs



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def rbs
  @rbs
end

#ref ⇒ Object

Returns the value of attribute ref

Returns:

  • (Object) —

    the current value of ref



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def ref
  @ref
end

#required ⇒ Object

Returns the value of attribute required

Returns:

  • (Object) —

    the current value of required



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def required
  @required
end

#ruby_name ⇒ Object

Returns the value of attribute ruby_name

Returns:

  • (Object) —

    the current value of ruby_name



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def ruby_name
  @ruby_name
end

#scalar ⇒ Object

Returns the value of attribute scalar

Returns:

  • (Object) —

    the current value of scalar



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def scalar
  @scalar
end

#wire_key ⇒ Object

Returns the value of attribute wire_key

Returns:

  • (Object) —

    the current value of wire_key



339
340
341
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 339

def wire_key
  @wire_key
end

Instance Method Details

#bound_facts ⇒ 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 numeric bounds every value the field carries is held to (for a list or map, each numeric one).



378
379
380
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 378

def bound_facts
  bounds.map { |key, value| "#{BiDiGenerate.camel_to_snake(key)}: #{BiDiGenerate.numeric_literal(value)}" }
end

#primitive_literal(value) ⇒ 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.

A single primitive string, or an array when a value may match several: a union of scalars (primitive), a scalar-tolerant union position (scalar), or a map's union of values (map).



384
385
386
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 384

def primitive_literal(value)
  value.is_a?(::Array) ? BiDiGenerate.word_array(value) : "'#{value}'"
end

#rbs_arg ⇒ 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 self.new keyword for this field — a user-supplied input carrying the field's value type. The ? prefix marks the field omittable; its value type already carries the schema's nullability, so nil is admitted only for a nullable field.



391
392
393
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 391

def rbs_arg
  required ? "#{ruby_name}: #{rbs}" : "?#{ruby_name}: #{rbs}"
end

#rbs_reader ⇒ 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 attr_reader type. A present value is rbs; an omitted optional reads back the UNSET sentinel, which a value type can't capture, so optionals stay untyped.



397
398
399
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 397

def rbs_reader
  "#{ruby_name}: #{required ? rbs : 'untyped'}"
end

#spec_entry(indent = 0, trailing: 0) ⇒ 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.

A Serialization::Record.define spec entry: name: 'jsonKey' shorthand, or name: {wire_key:, …} when the field carries JSON facts beyond its name. enum carries the allowed-values constant path, validated at construction.



344
345
346
347
348
349
350
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 344

def spec_entry(indent = 0, trailing: 0)
  meta = value_facts
  return "#{ruby_name}: '#{wire_key}'" if meta.empty?

  meta.unshift("wire_key: '#{wire_key}'")
  BiDiGenerate.wrap_call("#{ruby_name}: ", meta, indent, open: '{', close: '}', trailing: trailing)
end

#type_facts ⇒ 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 facts describing the value's type and shape: what the runtime reads it as and checks it against. For a list, ref/scalar/enum/primitive describe each element. map_of is the value primitive(s) of a string-keyed map ({*text => text}).



366
367
368
369
370
371
372
373
374
375
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 366

def type_facts
  facts = []
  facts << "ref: '#{ref}'" if ref
  facts << 'list: true' if list
  facts << "scalar: #{primitive_literal(scalar)}" if scalar
  facts << "enum: '#{enum}'" if enum
  facts << "primitive: #{primitive_literal(primitive)}" if primitive
  facts << "map: #{primitive_literal(map_of)}" if map_of
  facts + bound_facts
end

#value_facts ⇒ 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 JSON facts beyond the field's name, in the order Record.define reads them. A nullable const (literal / null) carries const: so the runtime rejects a value that is neither the literal nor null; const.nil? means the field has no const at all.



355
356
357
358
359
360
361
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 355

def value_facts
  facts = []
  facts << 'required: false' unless required
  facts << 'nullable: true' if nullable
  facts << "const: #{BiDiGenerate.ruby_literal(const)}" unless const.nil?
  facts + type_facts
end