Class: I2P::Key

Inherits:
Structure show all
Defined in:
lib/i2p/data/key.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Structure

#==, #eql?, parse, #size, #to_base64

Constructor Details

#initialize(data) ⇒ Key

Returns a new instance of Key.

Parameters:

  • data (String)


19
20
21
# File 'lib/i2p/data/key.rb', line 19

def initialize(data)
  @data = data.to_s
end

Instance Attribute Details

#dataString

Returns:

  • (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.

Parameters:

  • input (IO, StringIO)

Returns:



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_sString

Returns the binary string representation of this key.

Returns:

  • (String)


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.

Returns:

  • (Boolean)

Since:

  • 0.1.3



28
29
30
# File 'lib/i2p/data/key.rb', line 28

def valid?
  @data.size.eql?(self.class.const_get(:BYTESIZE))
end