Class: Solana::Ruby::Kit::Addresses::Address

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
Comparable
Defined in:
lib/solana/ruby/kit/addresses/address.rb

Overview

A validated, base58-encoded Solana address (32 bytes on-wire). Mirrors the TypeScript branded type:

type Address<TAddress extends string = string> = Brand<EncodedString<TAddress, 'base58'>, 'Address'>

Because Sorbet does not support nominal/branded string types, Address is a lightweight value object whose string representation is always a validated base58 string.

Direct Known Subclasses

OffCurveAddress

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Address



25
26
27
# File 'lib/solana/ruby/kit/addresses/address.rb', line 25

def initialize(value)
  @value = T.let(value, String)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



22
23
24
# File 'lib/solana/ruby/kit/addresses/address.rb', line 22

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



36
37
38
39
40
# File 'lib/solana/ruby/kit/addresses/address.rb', line 36

def <=>(other)
  return nil unless other.is_a?(Address)

  @value <=> other.value
end

#==(other) ⇒ Object Also known as: eql?



43
44
45
# File 'lib/solana/ruby/kit/addresses/address.rb', line 43

def ==(other)
  !!(other.is_a?(Address) && @value == other.value)
end

#hashObject



48
# File 'lib/solana/ruby/kit/addresses/address.rb', line 48

def hash = @value.hash

#inspectObject



33
# File 'lib/solana/ruby/kit/addresses/address.rb', line 33

def inspect = "#<#{self.class} \"#{@value}\">"

#to_sObject



30
# File 'lib/solana/ruby/kit/addresses/address.rb', line 30

def to_s = @value