Class: Scoutui::Base::QAccounts
- Inherits:
-
Object
- Object
- Scoutui::Base::QAccounts
- Defined in:
- lib/scoutui/base/q_accounts.rb
Instance Attribute Summary collapse
-
#accounts ⇒ Object
Returns the value of attribute accounts.
-
#dut ⇒ Object
Returns the value of attribute dut.
Instance Method Summary collapse
- #_find(id, attr) ⇒ Object
- #getPassword(u) ⇒ Object
- #getUserId(userid) ⇒ Object
- #getUserRecord(u) ⇒ Object
-
#initialize(f) ⇒ QAccounts
constructor
A new instance of QAccounts.
Constructor Details
#initialize(f) ⇒ QAccounts
Returns a new instance of QAccounts.
10 11 12 13 14 15 16 |
# File 'lib/scoutui/base/q_accounts.rb', line 10 def initialize(f) if !f.nil? @accounts = YAML.load_stream File.read(f) end end |
Instance Attribute Details
#accounts ⇒ Object
Returns the value of attribute accounts.
8 9 10 |
# File 'lib/scoutui/base/q_accounts.rb', line 8 def accounts @accounts end |
#dut ⇒ Object
Returns the value of attribute dut.
7 8 9 |
# File 'lib/scoutui/base/q_accounts.rb', line 7 def dut @dut end |
Instance Method Details
#_find(id, attr) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/scoutui/base/q_accounts.rb', line 18 def _find(id, attr) hit = @accounts.find { |h| h['account']['loginid'] == id } if !hit.nil? id=hit['account'][attr] end id end |
#getPassword(u) ⇒ Object
46 47 48 |
# File 'lib/scoutui/base/q_accounts.rb', line 46 def getPassword(u) _find(u, 'password') end |
#getUserId(userid) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/scoutui/base/q_accounts.rb', line 37 def getUserId(userid) id=nil hit = @accounts.find { |h| h['account']['loginid'].to_s == userid.to_s } if !hit.nil? id=hit['account']['loginid'] end id end |
#getUserRecord(u) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/scoutui/base/q_accounts.rb', line 26 def getUserRecord(u) hit=nil userid=getUserId(u) if !userid.nil? hit={'userid' => getUserId(u), 'password' => getPassword(u) } end hit end |