Class: Solana::Ruby::Kit::RpcTypes::Sol
- Inherits:
-
Object
- Object
- Solana::Ruby::Kit::RpcTypes::Sol
- Extended by:
- T::Sig
- Defined in:
- lib/solana/ruby/kit/rpc_types/sol.rb
Overview
SOL amounts expressed as a decimal fixed-point value with 9 decimal places. 1 SOL == 1_000_000_000 lamports, so Sol#raw is the exact Lamports count.
Mirrors TypeScript’s Sol (DecimalFixedPoint<‘unsigned’, 64, 9>).
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(raw) ⇒ Sol
constructor
A new instance of Sol.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
19 20 21 |
# File 'lib/solana/ruby/kit/rpc_types/sol.rb', line 19 def raw @raw end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
42 43 44 |
# File 'lib/solana/ruby/kit/rpc_types/sol.rb', line 42 def ==(other) other.is_a?(Sol) && @raw == other.raw end |
#hash ⇒ Object
47 |
# File 'lib/solana/ruby/kit/rpc_types/sol.rb', line 47 def hash = @raw.hash |
#inspect ⇒ Object
39 |
# File 'lib/solana/ruby/kit/rpc_types/sol.rb', line 39 def inspect = "#<#{self.class} #{self}>" |
#to_s ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/solana/ruby/kit/rpc_types/sol.rb', line 29 def to_s whole = @raw / 10**9 fraction = @raw % 10**9 return whole.to_s if fraction.zero? frac_str = fraction.to_s.rjust(9, '0').sub(/0+\z/, '') "#{whole}.#{frac_str}" end |