Class: SchwabRb::DataObjects::AccountNumbers
- Inherits:
-
Object
- Object
- SchwabRb::DataObjects::AccountNumbers
- Includes:
- Enumerable
- Defined in:
- lib/schwab_rb/data_objects/account_numbers.rb
Defined Under Namespace
Classes: AccountNumber
Instance Attribute Summary collapse
-
#accounts ⇒ Object
readonly
Returns the value of attribute accounts.
Class Method Summary collapse
Instance Method Summary collapse
- #account_numbers ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #find_by_account_number(account_number) ⇒ Object
- #find_hash_value(account_number) ⇒ Object
- #hash_values ⇒ Object
-
#initialize(data) ⇒ AccountNumbers
constructor
A new instance of AccountNumbers.
- #size ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ AccountNumbers
Returns a new instance of AccountNumbers.
15 16 17 |
# File 'lib/schwab_rb/data_objects/account_numbers.rb', line 15 def initialize(data) @accounts = data.map { |account_data| AccountNumber.new(account_data) } end |
Instance Attribute Details
#accounts ⇒ Object (readonly)
Returns the value of attribute accounts.
7 8 9 |
# File 'lib/schwab_rb/data_objects/account_numbers.rb', line 7 def accounts @accounts end |
Class Method Details
.build(data) ⇒ Object
10 11 12 |
# File 'lib/schwab_rb/data_objects/account_numbers.rb', line 10 def build(data) new(data) end |
Instance Method Details
#account_numbers ⇒ Object
32 33 34 |
# File 'lib/schwab_rb/data_objects/account_numbers.rb', line 32 def account_numbers @accounts.map(&:account_number) end |
#each(&block) ⇒ Object
48 49 50 |
# File 'lib/schwab_rb/data_objects/account_numbers.rb', line 48 def each(&block) @accounts.each(&block) end |
#empty? ⇒ Boolean
44 45 46 |
# File 'lib/schwab_rb/data_objects/account_numbers.rb', line 44 def empty? @accounts.empty? end |
#find_by_account_number(account_number) ⇒ Object
23 24 25 |
# File 'lib/schwab_rb/data_objects/account_numbers.rb', line 23 def find_by_account_number(account_number) @accounts.find { |account| account.account_number == account_number } end |
#find_hash_value(account_number) ⇒ Object
27 28 29 30 |
# File 'lib/schwab_rb/data_objects/account_numbers.rb', line 27 def find_hash_value(account_number) account = find_by_account_number(account_number) account&.hash_value end |
#hash_values ⇒ Object
36 37 38 |
# File 'lib/schwab_rb/data_objects/account_numbers.rb', line 36 def hash_values @accounts.map(&:hash_value) end |
#size ⇒ Object
40 41 42 |
# File 'lib/schwab_rb/data_objects/account_numbers.rb', line 40 def size @accounts.size end |
#to_h ⇒ Object
19 20 21 |
# File 'lib/schwab_rb/data_objects/account_numbers.rb', line 19 def to_h @accounts.map(&:to_h) end |