Class: Twobook::AccountQuery::NameQuery
- Inherits:
-
Twobook::AccountQuery
- Object
- Twobook::AccountQuery
- Twobook::AccountQuery::NameQuery
- Defined in:
- lib/twobook/account_query.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #construct_account ⇒ Object
-
#initialize(name, account: nil) ⇒ NameQuery
constructor
A new instance of NameQuery.
- #on(accounts) ⇒ Object
Methods inherited from Twobook::AccountQuery
#after, #and, #named, named, none, #none, #none?, #or, where, #where
Constructor Details
#initialize(name, account: nil) ⇒ NameQuery
Returns a new instance of NameQuery.
159 160 161 162 |
# File 'lib/twobook/account_query.rb', line 159 def initialize(name, account: nil) @name = name @account = account end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
157 158 159 |
# File 'lib/twobook/account_query.rb', line 157 def name @name end |
Instance Method Details
#construct_account ⇒ Object
164 165 166 167 |
# File 'lib/twobook/account_query.rb', line 164 def construct_account raise 'Could not construct an account from this name query: no data or category' if @account.nil? @account end |
#on(accounts) ⇒ Object
169 170 171 |
# File 'lib/twobook/account_query.rb', line 169 def on(accounts) accounts.select { |account| account.name == @name } end |