Sha256: 097ff03f0b41d087d028eaaaacbdfed1ce984e17b4d22b95e9db0af846b70711

Contents?: true

Size: 677 Bytes

Versions: 3

Compression:

Stored size: 677 Bytes

Contents

module Stellar
  Currency.class_eval do
    def self.native
      new(:native)
    end

    def self.iso4217(code, issuer)
      raise ArgumentError, "Bad :issuer" unless issuer.is_a?(KeyPair)
      ici = ISOCurrencyIssuer.new({currency_code:code, issuer:issuer.public_key})
      new(:iso4217, ici)
    end

    def to_s
      if switch == CurrencyType.native
        "native"
      else
        encoder = Stellar::Util::Base58.stellar
        issuer_address = encoder.check_encode(:account_id,iso_ci.issuer)
        "#{iso_ci.currency_code}/#{issuer_address}"
      end
    end

    def inspect
      label = switch.to_s
      "#<Stellar::Currency #{to_s}>"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stellar-base-0.0.3 lib/stellar/currency.rb
stellar-base-0.0.2 lib/stellar/currency.rb
stellar-base-0.0.1 lib/stellar/currency.rb