Class: NFS::XDR::Optional
- Inherits:
-
DynamicArray
- Object
- DynamicArray
- NFS::XDR::Optional
- Defined in:
- lib/nfs/xdr.rb
Instance Method Summary collapse
- #decode(string) ⇒ Object
- #encode(value) ⇒ Object
-
#initialize(type) ⇒ Optional
constructor
A new instance of Optional.
Constructor Details
#initialize(type) ⇒ Optional
Returns a new instance of Optional.
185 186 187 |
# File 'lib/nfs/xdr.rb', line 185 def initialize(type) super(type, 1) end |
Instance Method Details
#decode(string) ⇒ Object
197 198 199 200 201 202 203 204 205 |
# File 'lib/nfs/xdr.rb', line 197 def decode(string) result = super(string) if result.empty? nil else result[0] end end |
#encode(value) ⇒ Object
189 190 191 192 193 194 195 |
# File 'lib/nfs/xdr.rb', line 189 def encode(value) if value.nil? super([]) else super([value]) end end |