Class: GVariantMaybeType
- Inherits:
-
GVariantBasicType
- Object
- GVariantBasicType
- GVariantMaybeType
- Defined in:
- lib/gvariant.rb
Instance Attribute Summary
Attributes inherited from GVariantBasicType
#alignment, #default_value, #fixed_size, #id
Instance Method Summary collapse
-
#initialize(id, maybe_element) ⇒ GVariantMaybeType
constructor
A new instance of GVariantMaybeType.
- #read(buf) ⇒ Object
- #write(val) ⇒ Object
Methods inherited from GVariantBasicType
Constructor Details
#initialize(id, maybe_element) ⇒ GVariantMaybeType
Returns a new instance of GVariantMaybeType.
105 106 107 108 |
# File 'lib/gvariant.rb', line 105 def initialize(id, maybe_element) super(id, nil, maybe_element.alignment, nil, nil) @element = maybe_element end |
Instance Method Details
#read(buf) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/gvariant.rb', line 110 def read(buf) l = buf.length # Nothing return nil if l == 0 # Just if (@element.fixed_size) return nil if l != @element.fixed_size @element.read(buf) else @element.read(buf[0..l - 1]) end end |
#write(val) ⇒ Object
125 126 127 128 129 130 131 132 133 |
# File 'lib/gvariant.rb', line 125 def write(val) if val buf = @element.write(val) buf.concat(0) unless @element.fixed_size buf else "" end end |