Class: NFS::XDR::Enumeration

Inherits:
SignedInteger show all
Defined in:
lib/nfs/xdr.rb

Direct Known Subclasses

Boolean

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Enumeration

Returns a new instance of Enumeration.



36
37
38
39
40
41
42
43
# File 'lib/nfs/xdr.rb', line 36

def initialize(&block)
  @values = {}
  @names = {}

  if block_given?
    instance_eval(&block)
  end
end

Instance Method Details

#decode(string) ⇒ Object



54
55
56
# File 'lib/nfs/xdr.rb', line 54

def decode(string)
  @names[super(string)]
end

#encode(name) ⇒ Object



50
51
52
# File 'lib/nfs/xdr.rb', line 50

def encode(name)
  super(@values[name])
end

#name(v_name, value) ⇒ Object



45
46
47
48
# File 'lib/nfs/xdr.rb', line 45

def name(v_name, value)
  @values[v_name] = value
  @names[value] = v_name
end