Class: Stellar::AccountFlags

Inherits:
Object
  • Object
show all
Defined in:
lib/stellar/account_flags.rb

Class Method Summary collapse

Class Method Details

.make_mask(flags = nil) ⇒ Fixnum

Converts an array of Stellar::AccountFlags members into an Integer suitable for use in a SetOptionsOp.

Parameters:

Returns:

  • (Fixnum)

    the combined result


10
11
12
13
14
# File 'lib/stellar/account_flags.rb', line 10

def self.make_mask(flags = nil)
  flags ||= []

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

.parse_mask(combined) ⇒ Object

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>]

22
23
24
# File 'lib/stellar/account_flags.rb', line 22

def self.parse_mask(combined)
  members.values.select { |m| (m.value & combined) != 0 }
end