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
Methods inherited from GVariantBasicType
Constructor Details
#initialize(id, maybe_element) ⇒ GVariantMaybeType
Returns a new instance of GVariantMaybeType.
90 91 92 93 |
# File 'lib/gvariant.rb', line 90 def initialize(id, maybe_element) super(id, nil, maybe_element.alignment, nil, nil) @element = maybe_element end |
Instance Method Details
#read(buf) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/gvariant.rb', line 95 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 |