Class: XMLRPC::Base64
- Inherits:
-
Object
- Object
- XMLRPC::Base64
- Defined in:
- lib/xmlrpc/base64.rb
Class Method Summary collapse
Instance Method Summary collapse
- #decoded ⇒ Object
- #encoded ⇒ Object
-
#initialize(str, state = :dec) ⇒ Base64
constructor
A new instance of Base64.
Constructor Details
#initialize(str, state = :dec) ⇒ Base64
Returns a new instance of Base64.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/xmlrpc/base64.rb', line 44 def initialize(str, state = :dec) case state when :enc @str = Base64.decode(str) when :dec @str = str else raise ArgumentError, "wrong argument; either :enc or :dec" end end |
Class Method Details
.decode(str) ⇒ Object
64 65 66 |
# File 'lib/xmlrpc/base64.rb', line 64 def Base64.decode(str) str.gsub(/\s+/, "").unpack("m")[0] end |
.encode(str) ⇒ Object
68 69 70 |
# File 'lib/xmlrpc/base64.rb', line 68 def Base64.encode(str) [str].pack("m") end |
Instance Method Details
#decoded ⇒ Object
55 56 57 |
# File 'lib/xmlrpc/base64.rb', line 55 def decoded @str end |
#encoded ⇒ Object
59 60 61 |
# File 'lib/xmlrpc/base64.rb', line 59 def encoded Base64.encode(@str) end |