File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ module XMLRPC # :nodoc:
1313# You can use XMLRPC::Base64 on the client and server-side as a
1414# parameter and/or return-value.
1515class Base64
16+ include Comparable
1617
1718 # Creates a new XMLRPC::Base64 instance with string +str+ as the
1819 # internal string. When +state+ is +:dec+ it assumes that the
@@ -40,6 +41,11 @@ def encoded
4041 Base64 . encode ( @str )
4142 end
4243
44+ # Compare two base64 values, based on decoded string
45+ def <=>( other )
46+ return nil unless other . is_a? ( self . class )
47+ decoded <=> other . decoded
48+ end
4349
4450 # Decodes string +str+ with base64 and returns that value.
4551 def Base64 . decode ( str )
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+ require 'test/unit'
3+ require 'xmlrpc/base64'
4+
5+ module TestXMLRPC
6+ class Test_Base64 < Test ::Unit ::TestCase
7+ def test_equals
8+ refute_equal ( XMLRPC ::Base64 . new ( 'foobar' ) , 'foobar' )
9+ refute_equal ( XMLRPC ::Base64 . new ( 'foo' ) , XMLRPC ::Base64 . new ( 'bar' ) )
10+ assert_equal ( XMLRPC ::Base64 . new ( 'foobar' ) , XMLRPC ::Base64 . new ( 'foobar' ) )
11+ end
12+ end
13+ end
You can’t perform that action at this time.
0 commit comments