Class: NFS::XDR::FixedString
- Inherits:
-
Object
- Object
- NFS::XDR::FixedString
- Defined in:
- lib/nfs/xdr.rb
Direct Known Subclasses
Instance Method Summary collapse
- #decode(string) ⇒ Object
- #encode(value) ⇒ Object
-
#initialize(n) ⇒ FixedString
constructor
A new instance of FixedString.
Constructor Details
#initialize(n) ⇒ FixedString
Returns a new instance of FixedString.
95 96 97 |
# File 'lib/nfs/xdr.rb', line 95 def initialize(n) @n = n end |
Instance Method Details
#decode(string) ⇒ Object
103 104 105 106 |
# File 'lib/nfs/xdr.rb', line 103 def decode(string) superstring = string.slice!(0, XDR.pad(@n, 4)) superstring.nil? ? '' : superstring[0, @n] end |
#encode(value) ⇒ Object
99 100 101 |
# File 'lib/nfs/xdr.rb', line 99 def encode(value) [value.to_s].pack('a' + XDR.pad(@n, 4).to_s) end |