Class: Schema::Field

Inherits:
Capnp::Struct show all
Defined in:
lib/capnp/generator/schema.capnp.rb

Defined Under Namespace

Classes: GroupGroup, GroupOrdinal, GroupSlot, List, Which

Constant Summary collapse

DEFAULT_NAME =
nil
DEFAULT_CODE_ORDER =
0
DEFAULT_DISCRIMINANT_VALUE =
65535
NO_DISCRIMINANT =
65535

Instance Method Summary collapse

Methods inherited from Capnp::Struct

decode_pointer, from_pointer, #initialize

Constructor Details

This class inherits a constructor from Capnp::Struct

Instance Method Details

#annotationsObject



331
# File 'lib/capnp/generator/schema.capnp.rb', line 331

def annotations = Schema::Annotation::List.from_pointer(read_pointer(1))

#code_orderObject



329
# File 'lib/capnp/generator/schema.capnp.rb', line 329

def code_order = read_u16(0, 0)

#discriminant_valueObject



334
# File 'lib/capnp/generator/schema.capnp.rb', line 334

def discriminant_value = read_u16(2, 65535)

#groupObject



362
# File 'lib/capnp/generator/schema.capnp.rb', line 362

def group = GroupGroup.new(@data, @data_size, @pointers, @pointers_size)

#is_group?Boolean

Returns:

  • (Boolean)


376
# File 'lib/capnp/generator/schema.capnp.rb', line 376

def is_group? = which? == Which::Group

#is_slot?Boolean

Returns:

  • (Boolean)


360
# File 'lib/capnp/generator/schema.capnp.rb', line 360

def is_slot? = which? == Which::Slot

#nameObject



326
# File 'lib/capnp/generator/schema.capnp.rb', line 326

def name = Capnp::BufferString.from_pointer(read_pointer(0))

#ordinalObject



378
# File 'lib/capnp/generator/schema.capnp.rb', line 378

def ordinal = GroupOrdinal.new(@data, @data_size, @pointers, @pointers_size)

#slotObject



336
# File 'lib/capnp/generator/schema.capnp.rb', line 336

def slot = GroupSlot.new(@data, @data_size, @pointers, @pointers_size)

#to_objObject



444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/capnp/generator/schema.capnp.rb', line 444

def to_obj
  res = {}
  res["name"] = name&.to_obj
  res["code_order"] = code_order
  res["annotations"] = annotations&.to_obj
  res["discriminant_value"] = discriminant_value
  res["ordinal"] = ordinal.to_obj
  case which?
  when Which::Slot then res["slot"] = slot.to_obj
  when Which::Group then res["group"] = group.to_obj
  end
  res
end

#which?Boolean

Returns:

  • (Boolean)


426
# File 'lib/capnp/generator/schema.capnp.rb', line 426

def which? = Which.from_integer(read_u16(8, 0))