Class: I2P::Key
Direct Known Subclasses
Instance Attribute Summary collapse
Class Method Summary collapse
-
.read(input) ⇒ Key
Reads a key data structure from the given ‘input` stream.
Instance Method Summary collapse
-
#initialize(data) ⇒ Key
constructor
A new instance of Key.
-
#to_s ⇒ String
Returns the binary string representation of this key.
-
#valid? ⇒ Boolean
Returns ‘true` if this key is of the correct size.
Methods inherited from Structure
#==, #eql?, parse, #size, #to_base64
Constructor Details
#initialize(data) ⇒ Key
Returns a new instance of Key.
19 20 21 |
# File 'lib/i2p/data/key.rb', line 19 def initialize(data) @data = data.to_s end |
Instance Attribute Details
#data ⇒ String
15 16 17 |
# File 'lib/i2p/data/key.rb', line 15 def data @data end |
Class Method Details
.read(input) ⇒ Key
Reads a key data structure from the given ‘input` stream.
9 10 11 |
# File 'lib/i2p/data/key.rb', line 9 def self.read(input) self.new(input.read(const_get(:BYTESIZE))) end |
Instance Method Details
#to_s ⇒ String
Returns the binary string representation of this key.
36 37 38 |
# File 'lib/i2p/data/key.rb', line 36 def to_s @data end |
#valid? ⇒ Boolean
Returns ‘true` if this key is of the correct size.
28 29 30 |
# File 'lib/i2p/data/key.rb', line 28 def valid? @data.size.eql?(self.class.const_get(:BYTESIZE)) end |