Class: GVariantOffsetType
- Inherits:
-
GVariantBasicType
- Object
- GVariantBasicType
- GVariantOffsetType
- Defined in:
- lib/gvariant.rb
Direct Known Subclasses
GVariantArrayType, GVariantDictionaryType, GVariantTupleType
Instance Attribute Summary
Attributes inherited from GVariantBasicType
#alignment, #default_value, #fixed_size, #id
Instance Method Summary collapse
-
#initialize(id, alignment, default_value) ⇒ GVariantOffsetType
constructor
A new instance of GVariantOffsetType.
- #read_offset(buf, n) ⇒ Object
Methods inherited from GVariantBasicType
Constructor Details
#initialize(id, alignment, default_value) ⇒ GVariantOffsetType
Returns a new instance of GVariantOffsetType.
124 125 126 127 |
# File 'lib/gvariant.rb', line 124 def initialize(id, alignment, default_value) @offset_size = nil super(id, nil, alignment, nil, default_value) end |
Instance Method Details
#read_offset(buf, n) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/gvariant.rb', line 129 def read_offset(buf, n) l = buf.length if @offset_size.nil? if (l < 0xff) @offset_size = 1 @offset_unpack = 'C' elsif (l <= 0xffff) @offset_size = 2 @offset_unpack = 'S' elsif (l < 0xffffffff) @offset_size = 4 @offset_unpack = 'L' else raise ArgumentError.new("Offset range too big.") end end buf.unpack("@#{l + @offset_size * n}#{@offset_unpack}")[0] end |