Sha256: 3f898b0156b01381504688f0816e8e14c8e7b9d4cfbb2e8dff412af22aacbfbb
Contents?: true
Size: 517 Bytes
Versions: 4
Compression:
Stored size: 517 Bytes
Contents
require 'xdr' class ResultType < XDR::Enum member :ok, 0 member :error, 1 member :nonsense, 2 seal end class Result < XDR::Union switch_on ResultType, :type switch :ok switch :error, :message switch :default attribute :message, XDR::String[] end r = Result.new() r.set(:error, "hello") r.message! # => "hello" r.get # => "hello" r.set(:ok) r.get # => nil r.set(:nonsense) r.get # => nil # TODO case r when ResultType::OK ; puts "i'm ok!" when ResultType::ERROR ; puts "broken!" end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
payshares-xdr-0.0.2 | examples/union.rb |
xdr-0.0.3 | examples/union.rb |
xdr-0.0.2 | examples/union.rb |
xdr-0.0.1 | examples/union.rb |