lib/universa/keys.rb in universa-0.3.2 vs lib/universa/keys.rb in universa-0.3.3

- old
+ new

@@ -73,8 +73,28 @@ def packed s = get_packed s.force_encoding 'binary' s end + + # Compare KeyAddress with another KeyAddress or its string or even binary representation. + # Analyzes string length to select proper strategy. + def == other + if other.is_a?(KeyAddress) + super + elsif other.is_a?(String) + case other.size + when 37, 53 + # it is for sure packed representation + packed == other + else + # is should be string representation then + to_s == other + end + else + false + end + end + end end