Module: XDR::Int

Extended by:
Concerns::ConvertsToXDR, Concerns::IntegerConverter
Defined in:
lib/xdr/int.rb

Class Method Summary collapse

Methods included from Concerns::ConvertsToXDR

from_xdr, read, to_xdr, valid?, write

Methods included from Concerns::IntegerConverter

valid?

Class Method Details

.read(io) ⇒ Object



11
12
13
# File 'lib/xdr/int.rb', line 11

def self.read(io)
  read_bytes(io, 4).unpack1("l>")
end

.write(val, io) ⇒ Object

Raises:



5
6
7
8
9
# File 'lib/xdr/int.rb', line 5

def self.write(val, io)
  raise XDR::WriteError, "val is not Integer" unless val.is_a?(Integer)
  # TODO: check bounds
  io.write [val].pack("l>")
end