lib/museek_bindings/message/base.rb
# Defines museekd field, used in parsing.
#
# @example Define a string field
#  field :name, type: :string
#
# @example Define an array field named files, containing entries with name and size attributes.
#  field :files, type: [name: :string, size: uint32]
#
# @param name [Symbol] the name of field
# @param type [Symbol, Array<Hash>] type of a field.
#   - If passed value is a Symbol, possible values are :boolean, :uint32, :uint64, :string.
#   - If passed value is an Array, it should contain a hash. Keys are names, values are types.
#
# @return [void]
#
# @note You should define attributes in order they appear in service response.
# @since 0.0.1
Defines museekd field, used in parsing.
Defines museekd field used in parsing .
def field(name, type:)
      @schema ||= []
      schema << { name: name, type: type }
      define_getter(name, type)
    end
def field ( name , type : ) @schema ||= [ ] schema << { name : name , type : type } define_getter ( name , type ) end
Defines museekd field, used in parsing.
Defines museekd field used in parsing .
None
void
name
the name of field
the name of field
type
type of a field. - If passed value is a Symbol, possible values are :boolean, :uint32, :uint64, :string. - If passed value is an Array, it should contain a hash. Keys are names, values are types.
type of a field . - If passed value is a Symbol possible values are : boolean : uint32 : uint64 : string . - If passed value is an Array it should contain a hash . Keys are names values are types .
example
Define a string field field :name, type: :string
Define a string field field : name type : : string
example
Define an array field named files, containing entries with name and size attributes. field :files, type: [name: :string, size: uint32]
Define an array field named files containing entries with name and size attributes . field : files type : [ name : : string size : uint32 ]
note
You should define attributes in order they appear in service response.
You should define attributes in order they appear in service response .
since
None