3 Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
5 Released under the same term of license as Ruby.
12 This class is necessary for (('xmlrpc4r')) to determine that a string should
13 be transmitted base64-encoded and not as a raw-string.
14 You can use (({XMLRPC::Base64})) on the client and server-side as a
15 parameter and/or return-value.
18 --- XMLRPC::Base64.new( str, state = :dec )
19 Creates a new (({XMLRPC::Base64})) instance with string ((|str|)) as the
20 internal string. When ((|state|)) is (({:dec})) it assumes that the
21 string ((|str|)) is not in base64 format (perhaps already decoded),
22 otherwise if ((|state|)) is (({:enc})) it decodes ((|str|))
23 and stores it as the internal string.
25 --- XMLRPC::Base64.decode( str )
26 Decodes string ((|str|)) with base64 and returns that value.
28 --- XMLRPC::Base64.encode( str )
29 Encodes string ((|str|)) with base64 and returns that value.
32 --- XMLRPC::Base64#decoded
33 Returns the internal string decoded.
35 --- XMLRPC::Base64#encoded
36 Returns the internal string encoded with base64.
44 def initialize(str, state = :dec)
47 @str = Base64.decode(str)
51 raise ArgumentError, "wrong argument; either :enc or :dec"
64 def Base64.decode(str)
65 str.gsub(/\s+/, "").unpack("m")[0]
68 def Base64.encode(str)