Sha256: 15944d59d3f8eb2b35bcfe2e06a90234829bed93d20fbe552a0c29615b2d7328

Contents?: true

Size: 729 Bytes

Versions: 3

Compression:

Stored size: 729 Bytes

Contents

module Stellar
  class AccountFlags
    #
    # Converts an array of Stellar::AccountFlags members into
    # an Integer suitable for use in a SetOptionsOp.
    #
    # @param flags [Array<Stellar::AccountFlags>, nil] 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

3 entries across 3 versions & 1 rubygems

Version Path
stellar-base-0.32.0 lib/stellar/account_flags.rb
stellar-base-0.31.0 lib/stellar/account_flags.rb
stellar-base-0.30.0 lib/stellar/account_flags.rb