Class: BSV::Registry::CertificateFieldDescriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/bsv/registry/types.rb

Overview

Describes the structure and metadata for a single certificate field.

Used within CertificateDefinitionData to document the shape of each field in a certificate schema.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(friendly_name:, description:, type:, field_icon:) ⇒ CertificateFieldDescriptor

Returns a new instance of CertificateFieldDescriptor.

Parameters:

  • friendly_name (String)
  • description (String)
  • type (String)

    ‘text’, ‘imageURL’, or ‘other’

  • field_icon (String)


35
36
37
38
39
40
# File 'lib/bsv/registry/types.rb', line 35

def initialize(friendly_name:, description:, type:, field_icon:)
  @friendly_name = friendly_name
  @description   = description
  @type          = type
  @field_icon    = field_icon
end

Instance Attribute Details

#descriptionString (readonly)

Returns description of the field’s purpose.

Returns:

  • (String)

    description of the field’s purpose



23
24
25
# File 'lib/bsv/registry/types.rb', line 23

def description
  @description
end

#field_iconString (readonly)

Returns icon identifier for the field.

Returns:

  • (String)

    icon identifier for the field



29
30
31
# File 'lib/bsv/registry/types.rb', line 29

def field_icon
  @field_icon
end

#friendly_nameString (readonly)

Returns human-readable field name.

Returns:

  • (String)

    human-readable field name



20
21
22
# File 'lib/bsv/registry/types.rb', line 20

def friendly_name
  @friendly_name
end

#typeString (readonly)

Returns field type: ‘text’, ‘imageURL’, or ‘other’.

Returns:

  • (String)

    field type: ‘text’, ‘imageURL’, or ‘other’



26
27
28
# File 'lib/bsv/registry/types.rb', line 26

def type
  @type
end

Instance Method Details

#to_hHash

Serialise to a plain Hash for JSON encoding.

Returns:

  • (Hash)


45
46
47
48
49
50
51
52
# File 'lib/bsv/registry/types.rb', line 45

def to_h
  {
    'friendlyName' => @friendly_name,
    'description' => @description,
    'type' => @type,
    'fieldIcon' => @field_icon
  }
end