Class: FFIDB::Union

Inherits:
Object
  • Object
show all
Includes:
Symbolic
Defined in:
lib/ffidb/union.rb

Instance Method Summary collapse

Methods included from Symbolic

#<=>, #enum?, #function?, #kind, #kind_weight, #struct?, #to_yaml, #typedef?

Constructor Details

#initialize(name, fields = {}, comment = nil) ⇒ Union

Returns a new instance of Union.

Parameters:

  • name (Symbol, #to_sym)
  • fields (Map<Symbol, Type>) (defaults to: {})
  • comment (String, #to_s) (defaults to: nil)


13
14
15
# File 'lib/ffidb/union.rb', line 13

def initialize(name, fields = {}, comment = nil)
  super(name.to_sym, fields || {}, comment&.to_s)
end

Instance Method Details

#to_hHash<Symbol, Type>

Returns:

  • (Hash<Symbol, Type>)


29
30
31
32
33
34
35
# File 'lib/ffidb/union.rb', line 29

def to_h
  {
    name: self.name.to_s,
    comment: self.comment,
    fields: self.fields,
  }.delete_if { |k, v| v.nil? }
end

#to_sString

Returns:

  • (String)


23
24
25
# File 'lib/ffidb/union.rb', line 23

def to_s
  "union #{self.name}"
end

#union?Boolean

Returns:

  • (Boolean)


19
# File 'lib/ffidb/union.rb', line 19

def union?() return true end