Sha256: d8ea0cf627b274dd1a2d556fec96b5a3e29b19ce35696c01910c1d7257dcf0c2

Contents?: true

Size: 490 Bytes

Versions: 11

Compression:

Stored size: 490 Bytes

Contents

module XDR::Bool
  extend XDR::Concerns::ConvertsToXDR

  def self.write(val, io)
    case val
    when true  ; XDR::Int.write(1, io)
    when false ; XDR::Int.write(0, io)
    else ; raise XDR::WriteError, "Invalid bool value: #{val}"
    end
  end

  def self.read(io)
    val = XDR::Int.read(io)
    case val
    when 0 ; false
    when 1 ; true
    else ; raise XDR::ReadError, "Invalid bool value: #{val}"
    end
  end

  def self.valid?(val)
    val == true || val == false
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
payshares-xdr-0.0.2 lib/xdr/bool.rb
xdr-3.0.2 lib/xdr/bool.rb
xdr-3.0.1 lib/xdr/bool.rb
xdr-3.0.0 lib/xdr/bool.rb
xdr-2.0.0 lib/xdr/bool.rb
xdr-1.0.0 lib/xdr/bool.rb
xdr-0.1.0 lib/xdr/bool.rb
xdr-0.0.4 lib/xdr/bool.rb
xdr-0.0.3 lib/xdr/bool.rb
xdr-0.0.2 lib/xdr/bool.rb
xdr-0.0.1 lib/xdr/bool.rb