Class: GVariantVariantType

Inherits:
GVariantBasicType show all
Defined in:
lib/gvariant.rb

Instance Attribute Summary

Attributes inherited from GVariantBasicType

#alignment, #default_value, #fixed_size, #id

Instance Method Summary collapse

Methods inherited from GVariantBasicType

#align, #pad

Constructor Details

#initializeGVariantVariantType

Returns a new instance of GVariantVariantType.



137
138
139
# File 'lib/gvariant.rb', line 137

def initialize
  super('v', nil, 8, nil, { type: '()', value: {} })
end

Instance Method Details

#read(buf) ⇒ Object



141
142
143
144
# File 'lib/gvariant.rb', line 141

def read(buf)
  value, sep, type = buf[0..buf.length - 1].rpartition("\x00")
  { type: type, value: GVariant.read(type, value) }
end

#write(variant) ⇒ Object



146
147
148
149
150
# File 'lib/gvariant.rb', line 146

def write(variant)
  buf = GVariant.write(variant[:type], variant[:value])
  buf.concat(0)
  buf << variant[:type]
end