Class: NFS::XDR::DynamicArray
- Inherits:
-
Object
- Object
- NFS::XDR::DynamicArray
- Defined in:
- lib/nfs/xdr.rb
Direct Known Subclasses
Instance Method Summary collapse
- #decode(string) ⇒ Object
- #encode(value) ⇒ Object
-
#initialize(type, n) ⇒ DynamicArray
constructor
A new instance of DynamicArray.
Constructor Details
#initialize(type, n) ⇒ DynamicArray
Returns a new instance of DynamicArray.
154 155 156 157 |
# File 'lib/nfs/xdr.rb', line 154 def initialize(type, n) @type, @n = type, n @length = UnsignedInteger.new end |
Instance Method Details
#decode(string) ⇒ Object
175 176 177 178 179 180 181 |
# File 'lib/nfs/xdr.rb', line 175 def decode(string) length = @length.decode(string) Array.new(length) do @type.decode(string) end end |
#encode(value) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/nfs/xdr.rb', line 159 def encode(value) n = value.size if !@n.nil? && @n < n n = @n end result = @length.encode(n) n.times do |i| result << @type.encode(value[i]) end result end |