Sha256: 4c14f6e77a540be972391c2b6cb2af9027ef159c93a1c42ce3a6d3f684ccf154

Contents?: true

Size: 725 Bytes

Versions: 37

Compression:

Stored size: 725 Bytes

Contents

module Stellar
  class AccountFlags


    #
    # Converts an array of Stellar::AccountFlags members into
    # an Integer suitable for use in a SetOptionsOp.
    #
    # @param flags=nil [Array<Stellar::AccountFlags>] the flags to combine
    #
    # @return [Fixnum] the combined result
    def self.make_mask(flags=nil)
      flags ||= []

      flags.map(&:value).inject(&:|) || 0
    end

    #
    # Converts an integer used in SetOptionsOp on the set/clear flag options
    # into an array of Stellar::AccountFlags members
    #
    #  @param combined [Fixnum]
    #  @return [Array<Stellar::AccountFlags>]
    def self.parse_mask(combined)
      members.values.select{|m| (m.value & combined) != 0}
    end
  end
end

Version data entries

37 entries across 37 versions & 3 rubygems

Version Path
stellar-base-0.22.0 lib/stellar/account_flags.rb
stellar-base-0.21.0 lib/stellar/account_flags.rb
stellar-base-0.20.0 lib/stellar/account_flags.rb
stellar-base-0.19.0 lib/stellar/account_flags.rb
stellar-base-0.18.0 lib/stellar/account_flags.rb
stellar-base-0.17.0 lib/stellar/account_flags.rb
stellar-base-0.16.0 lib/stellar/account_flags.rb
stellar-base-0.15.0 lib/stellar/account_flags.rb
stellar-base-0.14.0 lib/stellar/account_flags.rb
stellar-base-0.13.0 lib/stellar/account_flags.rb
stellar-base-0.12.0 lib/stellar/account_flags.rb
stellar-base-0.11.0 lib/stellar/account_flags.rb
auction-ruby-base-0.1.3 lib/stellar/account_flags.rb
auction-ruby-base-0.1.2 lib/stellar/account_flags.rb
auction-ruby-base-0.1.1 lib/stellar/account_flags.rb
stellar-base-0.10.0 lib/stellar/account_flags.rb
stellar-base-0.9.0 lib/stellar/account_flags.rb
stellar-base-0.8.0 lib/stellar/account_flags.rb
stellar-base-0.7.0 lib/stellar/account_flags.rb
stellar-base-0.6.1 lib/stellar/account_flags.rb