Class: Universa::KeyAddress
- Inherits:
-
RemoteAdapter
- Object
- Delegator
- RemoteAdapter
- Universa::KeyAddress
- Defined in:
- lib/universa/keys.rb
Overview
The com.icodici.crypto.KeyAddress
extension. As it is immutable, caching is used to avoid unnecessary UMI calls.
Class Method Summary collapse
-
.from_packed(binary_string) ⇒ Object
Unpack from binary bytes.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compare KeyAddress with another KeyAddress or its string or even binary representation.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#packed ⇒ String
returns binary representation.
-
#to_s ⇒ String
String form of the key which could be used to unpack it back.
Methods inherited from RemoteAdapter
#__getobj__, #__setobj__, #initialize, #inspect, invoke_static, remote_class, remote_class_name, remote_field, static_method
Constructor Details
This class inherits a constructor from Universa::RemoteAdapter
Class Method Details
.from_packed(binary_string) ⇒ Object
Unpack from binary bytes
153 154 155 156 |
# File 'lib/universa/keys.rb', line 153 def self.from_packed(binary_string) binary_string.force_encoding 'binary' KeyAddress.new(binary_string) end |
Instance Method Details
#==(other) ⇒ Object
Compare KeyAddress with another KeyAddress or its string or even binary representation. Analyzes string length to select proper strategy.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/universa/keys.rb', line 166 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 |
#eql?(other) ⇒ Boolean
187 188 189 |
# File 'lib/universa/keys.rb', line 187 def eql?(other) self == other end |
#hash ⇒ Object
183 184 185 |
# File 'lib/universa/keys.rb', line 183 def hash to_s.hash end |
#packed ⇒ String
returns binary representation. It is not a string representation!
160 161 162 |
# File 'lib/universa/keys.rb', line 160 def packed @packed ||= get_packed.force_encoding 'binary' end |
#to_s ⇒ String
String form of the key which could be used to unpack it back
147 148 149 |
# File 'lib/universa/keys.rb', line 147 def to_s @string ||= toString() end |